{"action":"opened","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22412","labels_url":"https://api.github.com/repos/rails/rails/issues/22412/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22412/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22412/events","html_url":"https://github.com/rails/rails/issues/22412","id":118919271,"number":22412,"title":"db:structure:dump with MySQL includes current timestamp","user":{"login":"atsheehan","id":226221,"avatar_url":"https://avatars.githubusercontent.com/u/226221?v=3","gravatar_id":"","url":"https://api.github.com/users/atsheehan","html_url":"https://github.com/atsheehan","followers_url":"https://api.github.com/users/atsheehan/followers","following_url":"https://api.github.com/users/atsheehan/following{/other_user}","gists_url":"https://api.github.com/users/atsheehan/gists{/gist_id}","starred_url":"https://api.github.com/users/atsheehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atsheehan/subscriptions","organizations_url":"https://api.github.com/users/atsheehan/orgs","repos_url":"https://api.github.com/users/atsheehan/repos","events_url":"https://api.github.com/users/atsheehan/events{/privacy}","received_events_url":"https://api.github.com/users/atsheehan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-25T20:33:57Z","updated_at":"2015-11-25T20:33:57Z","closed_at":null,"body":"When running `rake db:structure:dump` in an application with MySQL configured, the generated `db/structure.sql` file contains the timestamp for when the dump was completed. Even if the underlying database does not change, running `rake db:structure:dump` will produce a different output each time. Because `db/structure.sql` is often version controlled, this timestamp will generate a lot of noise if each change is committed.\r\n\r\nIf the `config.active_record.schema_format = :sql` option is set, this command is also run after `rake db:migrate`, updating the `db/structure.sql` file even if no new migrations are run.\r\n\r\nA test case has been included at [https://gist.github.com/atsheehan/3477a1659b97741de4ae](https://gist.github.com/atsheehan/3477a1659b97741de4ae). It creates a new MySQL database, performs two structure dumps within a few seconds of each other, and checks if they differ. This test requires MySQL to be installed and running locally.\r\n\r\nThis behavior of `mysqldump` is also described at [https://bugs.mysql.com/bug.php?id=31077](https://bugs.mysql.com/bug.php?id=31077). It appears that a `--skip-dump-date` flag has been added around 2007 that avoids this issue.\r\n\r\nIf this sounds like a valid issue, I believe the fix would be to include the `--skip-dump-date` option [here](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/mysql_database_tasks.rb#L58-L61). Adding an extra flag when calling an external program might break old versions of `mysqldump`, but since the patch to include it was from 2007 I would assume most clients support it by now."}}