This adds custom commands which dump or deploy SQL data to/from databases. As database servers are usually not reachable through the internet, it can tunnel its connection through SSH.
This was originally meant as a simple tool to refresh the DDEV database from time to time during feature development with current live data. A fancy interface was built to facilitate adoption with colleagues ;) - the normal workflow would be ddev dump-db my-remote-live-server; ddev deploy-db ddev
.
It came in handy during TYPO3 upgrades, too when being able to diff SQL data table by table helps facilitate single update steps. This is a controversial topic, but during upgrades I found it helpful to even git the data/SQL together with the code and thus be able to completely undo steps (even if they have side effects on the data) when necessary.
Copy the web/ directory into your project's .ddev/commands/web.
Without configuration this lets you dump and and deploy the local (called ‹ddev›) database.
In order to add other hosts, see web/targets/README.txt for the config file structure. You basically need SSH and DB connection info. You can use private keys (e.g. via ddev auth ssh
) or a password prompt to connect.
Running ddev deploy-db
or ddev dump-db
will show the available host configurations and parameters.
ddev dump-db
will save the SQL data at ./data/sql/records and ./data/sql/struct.
ddev deploy-db
also expects .sql files to be in any of these directories. For the ‹ddev› target this is functionally identical to cat ./data/sql/struct/*.sql ./data/sql/records/*.sql | ddev mysql
.
This is what
ddev dump-db my-host
looks like:
Contributed by @jonaseberle