-
Notifications
You must be signed in to change notification settings - Fork 18
Description
During the db:import task, all tables are dropped and recreated unless the commandline option importTaskDoNotDropAllTablesBeforeImport is set:
deployer-extended-database/deployer/db/task/db_import.php
Lines 68 to 81 in 860cbe2
| if (empty($optionUtility->getOption('importTaskDoNotDropAllTablesBeforeImport'))) { | |
| runLocally(sprintf( | |
| '%s --defaults-file=%s %s %s --add-drop-table --no-data | ' . | |
| 'grep -e \'^DROP \| FOREIGN_KEY_CHECKS\' | %s --defaults-file=%s %s -D%s', | |
| get('local/bin/mysqldump'), | |
| escapeshellarg($tmpMyCnfFile), | |
| DatabaseUtility::getSslCliOptions($databaseConfig), | |
| escapeshellarg($databaseConfig['dbname']), | |
| get('local/bin/mysql'), | |
| escapeshellarg($tmpMyCnfFile), | |
| DatabaseUtility::getSslCliOptions($databaseConfig), | |
| escapeshellarg($databaseConfig['dbname']) | |
| )); | |
| } |
I do not understand why this is done or necessary since the default configuration for both db_export_mysqldump_options_structure and db_export_mysqldump_options_data already do add a DROP TABLE IF EXISTS. So if both structure.sql and data.sql exists, a db:import call essentially does the following:
- Export all table structures and then import it, thus dropping and the creating the tables again.
- strucutre.sql drops each table and then recreates it
- data.sql drops each table, recreates it and imports its data
So overall, during an import the tables are destroyed and recreated three times. I suggest removing the first subtask (export, drop and recreate) entirely, including the importTaskDoNotDropAllTablesBeforeImport flag, as it also does not follow the ignore_tables_out option. This means all tables are essentially truncated, even those defined by ignore_tables_out.
Additionally, the defaults for for db_export_mysqldump_options_data should include --no-create-info, as it really should only contain the data and not the structure, thus not trigger another drop&create table.