How can ddev automatically create additional datab

2019-04-10 23:02发布

问题:

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.

回答1:

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'@'%';"


标签: ddev