Reputation: 458
One of the DDEV sites I manage uses a database that includes a prefix. The default behavior for DDEV is to recreate the settings.ddev.php
on every start. But that obviously overwrites anything added, purging any manual addition of the prefix.
Is the assumed solution to stop DDEV from overwriting the file? Or to create another settings file (like settings.local.php
) to override what's been overridden? Or am I missing something?
This just seems like something that would exist as a simple variable in the config to generate a more accurate settings.ddev.php
file. Thanks!
Upvotes: 1
Views: 1033
Reputation: 591
When it comes to installing a new Drupal site from scratch with DDEV, I'd leave config.yaml alone unless you want to set your upload_dirs
there (but that's a different topic). I've found that changing the type to php when using Drupal causes some havoc as the installer won't appreciate having files in your project directory already. In any case, I would suggest leaving the type as drupal. If you're using WordPress, that's a different story.
Assuming you're using DDEV with Composer and Drush, once you've run:
ddev composer require --dev drush/drush
Set the db prefix (and the Private File Path if needed) in web/sites/default/settings.php
, found around line 93 for Drupal 10:
$databases = [];
Replace that line with:
$databases['default']['default'] = [
'prefix' => 'myprefix_',
];
// Set the private file path
$settings['file_private_path'] = '../private';
Then finish the installation with
ddev drush site:install --account-name=myaccount --account-pass=mypass -y
For complete instructions, see this article by PureWebMedia.biz
Upvotes: 0
Reputation: 5112
I decided to use a version of the second suggestion:
// Automatically generated include for settings managed by ddev.
$ddev_settings = dirname(__FILE__) . '/settings.ddev.php';
if (getenv('IS_DDEV_PROJECT') == 'true' && is_readable($ddev_settings)) {
require $ddev_settings;
$databases['default']['default']['prefix'] = "drupal_";
}
I just added the $databases
line. The rest was already there.
Upvotes: 0
Reputation: 12815
There are a few straightforward answers:
Upvotes: 1