wunderio / ddev-drupal

Work in progress of template for DDEV Drupal projects
0 stars 0 forks source link

#11 Add syncdb command. #12

Closed hkirsman closed 4 months ago

hkirsman commented 4 months ago

Overview

In Lando we have syncdb command that imports production database via SSH tunnel and imports the db into local env. This is adding the same feature to this project.

The logic of the script:

  1. it's based on https://github.com/wunderio/unisport/blob/master/.lando/syncdb.sh
  2. cr and other tasks are done in the post db script https://github.com/wunderio/ddev-drupal/pull/12/files#diff-858ae242bb89b1f7b21f07c96a99602c883ecb253d0a24a27af902e1d52ab807
  3. instead of using @prod alias we use ssh command as for some reason drush alias just times out
  4. with ssh we download the db and then import that, after everything is done we remove the the file.

Testing

  1. Install this version where you have SILTA support and you know lando syncdb works in Lando:
ddev composer require wunderio/ddev-drupal:dev-feature/11-Create-syncdb-task-to-sync-wunder-production-db-to-local --dev
  1. Try syncdb ddev syncdb
hkirsman commented 4 months ago

Based on @deiviic comment I've added skipping of cache tables in the import. In one of the real case scenarios the difference of dump file was from 517MB to 86MB.

hkirsman commented 4 months ago

I'm thinking of re-ordering the commands a bit - instead of dropping the db, that should be done after import worked. In case you forget to enable VPN, db would be dropped, but why do it before if the most error prone task could fail.

Or maybe just remove the drop. ddev import should do that.

artursv commented 4 months ago

instead of dropping the db

Do we have to drop it? At lando clears DB before doing import - have not checked if ddev does the same.

hkirsman commented 4 months ago

instead of dropping the db

Do we have to drop it? At lando clears DB before doing import - have not checked if ddev does the same.

Yeah, we don't need extra drop. I've tested that import works fine without extra drop and there's also extra command not to drop

image