mirror of
https://github.com/opdavies/build-configs.git
synced 2025-01-23 02:27:33 +00:00
feat: allow for adding extra databases
Allow for declaring extra databases that should be created when the project is first started. This is done by adding an `extra_databases` key to `database`, containing a list of database names. ```yaml database: type: mariadb version: 10 extra_databases: - tinhat - freshcover ```
This commit is contained in:
parent
692151d26c
commit
4d034d9ba2
|
@ -78,6 +78,13 @@ $app->command(
|
|||
['env.example', '.env.example'],
|
||||
]);
|
||||
|
||||
$extraDatabases = Arr::get($configurationData, 'database.extra_databases', []);
|
||||
if (count($extraDatabases) > 0) {
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem->mkdir("{$outputDir}/tools/docker/images/database/root/docker-entrypoint-initdb.d");
|
||||
$filesToGenerate->push(['extra-databases.sql', 'tools/docker/images/database/root/docker-entrypoint-initdb.d/extra-databases.sql']);
|
||||
}
|
||||
|
||||
if (false !== Arr::get($configurationData, "justfile", true)) {
|
||||
$filesToGenerate->push(['justfile', 'justfile']);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,22 @@ final class ConfigurationValidator implements ValidatorInterface
|
|||
new Assert\Type('string'),
|
||||
],
|
||||
|
||||
'database' => new Assert\Optional(),
|
||||
'database' => new Assert\Collection(
|
||||
[
|
||||
'extra_databases' => new Assert\Optional(
|
||||
[
|
||||
new Assert\Type(['type' => 'array']),
|
||||
new Assert\All(
|
||||
[
|
||||
new Assert\Type(['type' => 'string'])
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
'type' => new Assert\Type(['type' => 'string']),
|
||||
'version' => new Assert\Type(['type' => 'integer']),
|
||||
]
|
||||
),
|
||||
|
||||
'drupal' => new Assert\Optional(),
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ services:
|
|||
memory: "${DOCKER_MYSQL_MEMORY:-0}"
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
{{ database.extra_databases is not empty ? '- ./tools/docker/images/database/root/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d' : '' }}
|
||||
env_file:
|
||||
- .env
|
||||
labels:
|
||||
|
|
5
templates/extra-databases.sql.twig
Normal file
5
templates/extra-databases.sql.twig
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% for database in database.extra_databases %}
|
||||
CREATE DATABASE {{ database }};
|
||||
GRANT ALL PRIVILEGES ON {{ database }}.* TO drupal@'%' IDENTIFIED BY 'drupal';
|
||||
|
||||
{% endfor %}
|
Loading…
Reference in a new issue