dump_schema_information: explicitly order inserts into schema_migrations #3477

merged 1 commit into from Oct 31, 2011

3 participants


dump_schema_information: now explicitly orders inserts into schema_migrations table by version value

We use active_record.schema_format = :sql as our schema dump format, and the db/development_structure.sql sees quite a bit of trivial churn in the git history due to migrations having run in different orders, as migrations are created on different feature branches over time. With this trivial fix, only added/removed migrations will create changes to the schema dump file.

The complete activerecord test suite with all database drivers pass with this change. Unfortunately, that doesn't say a big deal, as dump_schema_information is only called by the db:structure:dump rake-task. Local manual testing does confirm the change, though.

Comments on this change?

Ruby on Rails member

+1. I have seen this issue myself. Could you please write a test for it? Thanks!

@rud rud dump_schema_information: explicitly order inserts into schema_migrati…
…ons table

This change reduces churn in the db/development_structure.sql file when using :sql as
active_record.schema_format, and makes comparing diffs much easier.

Test ensures the output SQL-statements are lexically ordered by version.

Test added - took the liberty of updating the patch with test added. Does this also look sane to you?

@josevalim josevalim merged commit 2407a7a into rails:master Oct 31, 2011
Ruby on Rails member

Looks good, merged.


Awesome, thank you @josevalim :)


The order of the arguments should be the other way around. Fixed in 1afe269

Thank you for that fix!

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