ironstar-io / tokaido

Zero-conf Drupal Local Development Environments with Docker
https://tokaido.io
BSD 3-Clause "New" or "Revised" License
57 stars 10 forks source link

`tok snapshot` should drop the database #204

Closed ironmike-au closed 4 years ago

ironmike-au commented 4 years ago

tok snapshot currently takes a copy of the database without the DROP DATABASE command included. this causes the restored database to be overlayed on top of the existing database.

The logic for this needs to be updated to use at least the --opt parameter for mysqldump. This should be the default, so it would be good to work out why that's not taking place.

garrettw commented 4 years ago

Would it not be preferable, instead, to have Tokaido automatically drop all the existing tables when restoring from a snapshot without putting that command in the exported SQL?

ironmike-au commented 4 years ago

Hi Garrett!

tok snapshot restore lets users import databases from external sources. It's possible the user might want to not DROP DATABASE during a restore from an external source, so I think forcing this behaviour via Tokaido might cause issues for those use cases (rare as they may be).

By letting the user's .sql file specify the DROP DATABASE command, we're giving them more control over what happens during their import.

I think making Tokaido default to including DROP DATABASE in any dumps made with Tokaido will bring it's behaviour more in line with the standard expectation of other tools, like drush.

ironmike-au commented 4 years ago

this is fixed now and will be included in the upcoming 1.12 release