When DDEV is building a Drupal site (Drupal 7 in my case), it's using a settings template described here:
https://github.com/drud/ddev/blob/8be3d67394f157bbe3554bca0e8e0be9f62aaf7d/pkg/ddevapp/drupal.go#L53
The database driver is hard coded, which requires me to override the database connection on my local settings, when I use the PostgreSQL contrib from here: https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/postgres
This is the generated code in my settings.ddev.php file:
$databases['default']['default'] = array(
'database' => "db",
'username' => "db",
'password' => "db",
'host' => $host,
'driver' => "mysql",
'port' => $port,
'prefix' => "",
);
Since I only need one database server and I'm using the postgresql from above, I disabled the db + dba containers and added postgresql-client to my config.yaml:
webimage_extra_packages: [postgresql-client]
omit_containers: ["db","dba"]
However, I have no way to configure the database host, port nor driver. Would be great to have them as an option. Because right now I have to add an ugly extra setting file which obfuscates my project repository and settings.php:
// #ddev-custom: load postgres db connection (not supported by DDEV config yet)
if (getenv('IS_DDEV_PROJECT') == 'true') {
include dirname(__FILE__) . '/settings.ddev.postgres.php'
}
Which contains:
<?php
# DDEV POSTGRES SETTINGS
$databases['default']['default'] = array(
'database' => "db",
'username' => "db",
'password' => "db",
'host' => 'postgres',
'port' => '5432',
'driver' => 'pgsql',
'prefix' => '',
);
This solution works, but isn't beautiful - especially since Drupal supports mysql + pgsql by default, so why doesn't DDEV? Adding full postgresql support for ddev config is a lot to ask, so I rather ask for the little config change (support of config variables for host,port and driver). This would be much appreciated.
We'd love to have people ask for explicit Postgres support; Currently the community-supported way to do this is in https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/postgres - it's not hard, but it's not direct support either. Are you using that?
Basically we implement features when people ask for them, and this is the first issue I can find where somebody actually asked :)
I should mention that you don't have to let ddev create settings files at all. There are a number of ways to do this, but one is disable_settings_management: true. Then you have complete control of settings.php etc.
More about settings management: https://ddev.com/ddev-local/controlling-cms-settings-files-in-ddev-local/
Many thanks for your feedback, yes we're on the same page here. I'm already using the postgres service from the contrib repository. I'm also aware of the settings management, but there is more attached to it in the long run.
Making this "small" config amendment would allow Drupal project owners which depend on a PostgreSQL database a much faster ramp up time. Being able to configure host, port and driver would also allow us independent from Drupal to update the database commands of ddev (or contrib commands) itself.
The setup I'm running above let me create the postgre container as well override the settings for Drupal, so that I could at least use the drush commands. But it would be great if we could also extend the commands and hooks for ddev, so that we can extend the features of the postgre addon (e.g. database import, export, sync). It would be great if we don't have to depend on Drupal + Drush for this!
I have a couple of projects running with PostgreSQL and Drupal, therefore I will use this opportunity to make some "reasonable" feature requests like this one so that I can easier contribute to the extension.
Hi! I can also confirm the same issue with PostgreSQL. And yes, only one way it is not using settings.ddev.php. :(
Most helpful comment
We'd love to have people ask for explicit Postgres support; Currently the community-supported way to do this is in https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/postgres - it's not hard, but it's not direct support either. Are you using that?
Basically we implement features when people ask for them, and this is the first issue I can find where somebody actually asked :)
I should mention that you don't have to let ddev create settings files at all. There are a number of ways to do this, but one is
disable_settings_management: true. Then you have complete control of settings.php etc.