Skip to content

[database:add] add option to add settings to $databases['default']['default'] #4142

Description

@Kwadz

The command database:add does not allow to create the first database defined by $databases['default']['default']. This can be useful in case a fresh install that you want to connect to an existing database. Currently the command only allows adding database in addition to the default one.

I suggest adding an option like --default to add the default database. The current template add.php.twig is:

$databases['{{ database }}']['default'] = [
  'database' => '{{ database }}',
  'username' => '{{ username }}',
  'password' => '{{ password }}',
  'host' => '{{ host }}',
  'port' => '{{ port }}',
  'driver' => '{{ driver }}',
  'prefix' => '{{ prefix }}',
];

I suggest adding add-default.php.twig:

$databases['default']['default'] = [
  'database' => '{{ database }}',
  'username' => '{{ username }}',
  'password' => '{{ password }}',
  'host' => '{{ host }}',
  'port' => '{{ port }}',
  'driver' => '{{ driver }}',
  'prefix' => '{{ prefix }}',
];

This new template would be called instead, when using --default option.

What do you think? I'd be pleased to do a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions