Problem/Motivation
The list of tables provided by Drupal\Core\Database\Query\PlaceholderInterface\Schema::findTables() is not guaranteed to be in a specific order. This makes manipulating database dumps created by the db-tools.php command problematic.
Steps to reproduce
Import a database dump created on Drupal 8.9.
Export the database using db-tools.php on an 9.3 site.
Expected behavior:
There are minimal differences in the output with the database tables in the same order.
Actual behavior:
The tables are not in the same order, resulting in a huge git diff when comparing the database dump against an existing file.
Proposed resolution
Use asort() in Drupal\Core\Command\DbDumpCommand::getTables() to sort the tables.
Remaining tasks
Provide a patch.
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
The output of the db-tools.php command will now always sort the output based upon the alphabetical sorting of the table names.
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal-n3228237-2.patch | 447 bytes | DamienMcKenna |
Comments
Comment #2
DamienMcKennaThis adds the asort() function as suggested.
Comment #3
quietone CreditAttribution: quietone as a volunteer commentedI mentioned the sorting problem in #838992-52: Change the uid field from integer to serial by leveraging NO_AUTO_VALUE_ON_ZERO on MySQL but failed to take it any further. Thanks @DamienMcKenna for doing so.
I am all for sorting these tables, anything to make it easier to work with a dump file is worth the extra bit of code. Anyone that has a dump that is not sorted adding sorting can just import/export and have a sorted dump file. The reverse isn't true.
I'd like to have this.
Comment #5
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!
Comment #7
DamienMcKennaThanks for the quick commit, catch!