webksde / ddev-vscode-devcontainer-drupal-template

Drupal DDEV based development container with attached Visual Studio Code
23 stars 3 forks source link

Add ddev drowl-reset-db command to easily reset the DB to initial (or selected) state #95

Closed JPustkuchen closed 1 year ago

JPustkuchen commented 2 years ago

Problem:

There are cases where you need to reset the database back to the initial (or selected) state for example to test module installation.

Using backup-migrate or PHPMyAdmin is quite time-consuming. Especially because you manually need to DROP all tables before the import (in both cases)

Proposed solution:

Create a drowl-reset-db command with one optional parameter (the dump name from the data/sql directory). If parameter is not given, use the initial backup (db-state after drowl-init / drowl-init-from-existing).

Before deleting the "db" database and restoring from the file, show a Y/N confirmation to the user with the directory and file name that will be restored.

The initial dump should be named accordingly to the time it was taken: db-complete-dump-INITIAL.sql or something like that - there may be better names.

JPustkuchen commented 1 year ago

Perhaps backup_migrate via drush command would be the better place to invest time into... so we could use it everywhere. Especially it needs real cleanups, currently I think it keeps old tables and doesn't flush all tables before restoring. That's bad.

So if importing an sql file works well and comfortable in ddev, I think that would be enough.

joshsedl commented 1 year ago

Sounds good to me!

Closing this.