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.
active_record.schema_format = :sql
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?
+1. I have seen this issue myself. Could you please write a test for it? Thanks!
dump_schema_information: explicitly order inserts into schema_migrati…
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?
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!