Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mysqldump #23301

Merged
merged 1 commit into from
Jun 17, 2016
Merged

Improve mysqldump #23301

merged 1 commit into from
Jun 17, 2016

Conversation

ppworks
Copy link
Contributor

@ppworks ppworks commented Jan 28, 2016

After we running rake db:structure:dump in project members each other, there might have diff on db/structure.sql as below.

--- MySQL dump 10.13  Distrib 5.7.9, for osx10.9 (x86_64)
+-- MySQL dump 10.13  Distrib 5.6.23, for osx10.10 (x86_64)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB AUTO_INCREMENT=437 DEFAULT CHARSET=utf8;

Because default output of mysqldump includes comments like MySQL version and AUTO_INCREMENT default value and so on.

In addition, after we running rake db:migrate when we set config.active_record.schema_format=:sql in confing/application.rb, there might have different db/structure.sql as below.

--- Dump completed on 2016-01-28 13:34:00
+-- Dump completed on 2016-01-28 13:48:05

So, I added additional options to "mysqldump" command and I removed AUTO_INCREMENT default values from dumped SQL.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@pixeltrix
Copy link
Contributor

For reference previous discussion about this: #8004

@ppworks
Copy link
Contributor Author

ppworks commented Jan 28, 2016

Thanks for your reference!
I deleted https://github.com/ppworks/rails/commit/5044db4b1 .

@ppworks
Copy link
Contributor Author

ppworks commented Jan 28, 2016

Thank you, I'll try to do this to avoid AUTO_INCREMENT diff.

@arthurnn
Copy link
Member

arthurnn commented Mar 7, 2016

r? @arthurnn

@rails-bot rails-bot assigned arthurnn and unassigned sgrif Mar 7, 2016
@metaskills
Copy link
Contributor

So 👀 this issue.

@jeremy
Copy link
Member

jeremy commented May 19, 2016

Are --skip-comments and --skip-dump-date compatible with all MySQL 5.x? With MariaDB 5.x and 10.x?

@arthurnn
Copy link
Member

I think if you skip-comments you dont need to skip-dump-date too. as the date is considered a comment.
At least I tested locally with skip-comment only and it worked.
Can you change to include only that?

@jeremy I see skip-comments on 5.5 https://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_dump-date and maria https://mariadb.com/kb/en/mariadb/mysqldump/

@ppworks
Copy link
Contributor Author

ppworks commented Jun 17, 2016

@arthurnn Thanks for your review.

@arthurnn
Copy link
Member

ありがとうございます

@arthurnn arthurnn merged commit 6d4df1d into rails:master Jun 17, 2016
@jaredbeck
Copy link
Contributor

Am I understanding correctly that rails 5.1 will no longer include the AUTO_INCREMENT=123 comment in my structure.sql? If so, that is awesome.

knu added a commit to knu/git-merge-structure-sql that referenced this pull request Nov 30, 2018
Rails merged [this PR](rails/rails#23301) to
run mysqldump with `--skip-comments`.
@Qwertie-
Copy link

@jaredbeck Late reply but maybe this is useful to others. But as far as I can tell, this change doesn't actually get rid of the autoincrement but it does get rid of other bits of useless info / merge conflict sources. Seems like the best way to remove this is one of the regex replace scripts floating around as mysqldump doesn't seem to have any setting to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants