smart_db_tools
Smart DB Tools is a module🤔 which implements the feature requested in #3213633: Improve DX of maintaining migration database fixtures: provide an option for creating per-table database fixtures in DbDumpcommand.
It contains an enhanced version of the DbToolsApplication of Drupal core with an improved dump command that allows users to save a database dump into multiple PHP scripts – so each database table will be exported in its own file.
This functionality greatly reduces the time spent on cleaning changed database fixture scripts.
Usage
The application is backward-compatible with the DbToolsApplication in Drupal core. The only difference is that if the --split-destination option is passed to the script, then instead of a single file, per-table database PHP scripts will be generated. The value of the --split-destination option is the name of the main PHP database dump file.
To lower memory consumption (both on export and import), tables with more than 1000 records are also exported into multiple files (this is by default). This option can be changed by providing a --subsplit-limit option set to the desired value. Using --subsplit-limit 1000 works well with PHP memory_limit set to 256M. Setting this limit to a number lower than 1 disables this behavior.
Example
php modules/contrib/smart_db_tools/scripts/smart-db-tools.php dump\
--database fixture_connection\
--subsplit-limit 5000\
--split-destination modules/custom/db-dump.php