Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can ddev automatically create additional databases?

Tags:

ddev

This is a followup question to How can I create and load a second database in ddev?. It is about doing that task automatically.

One use case for this is developing a migration to Drupal from another MySQL database, and collaborating with others on the migration. If the database name can be set by ddev, additional developers can get the database created automatically, and additional databases can be added to their settings.local.php, using known values.

like image 816
David Lanier Avatar asked Jul 09 '18 20:07

David Lanier


1 Answers

Try this in your project's config.yaml:

hooks:
  post-start:
    - exec: mysql -uroot -proot -hdb -e "CREATE DATABASE IF NOT EXISTS another_db; GRANT ALL ON another_db.* TO 'db'@'%';"
like image 95
rfay Avatar answered Nov 10 '22 01:11

rfay