I set up a website using Drupal 10 and PostgreSQL but due to a communication delay, I just found out from the server team that the database on the staging/live servers is MySQL and not PostgreSQL. I now face the issue of switching my site to use MySQL instead.
My goal is to switch the database from my local PostgreSQL database to my newly created local MySQL database so that I can easily migrate the site to the staging and live servers in the future. Alternatively, I would like to know if this is futile and if I am forced to start development from scratch.
Attempted Solutions
I did a lot of research to try to find information on how to make the change. I couldn't find any Drupal documentation on how to do this. I only found information on how to migrate the database, but it seemed to be specific to migrating to the same environment and not switching databases completely.
I found this 11 year old article which made it seem like I simply had to edit my settings.php
file and change the $databases
array.
My $databases
array in my settings.php
file looks like this:
$databases['default']['default'] = array (
'database' => (database_name),
'username' => (user),
'password' => (password),
'prefix' => '',
'host' => 'localhost',
'port' => '5432',
'namespace' => 'Drupal\\pgsql\\Driver\\Database\\pgsql',
'driver' => 'pgsql',
'autoload' => 'core/modules/pgsql/src/Driver/Database/pgsql/',
);
Changing the database name, user, pass and port were easy enough, but I don't know what to change the namespace, driver, or autoload to, so I wasn't able to complete this attempt. I am frankly not sure if I am even on the right track or not.
Question
How do I switch my Drupal 10 site from PostgreSQL to MySQL in a way that preserves as much data as possible?
Is this even possible, or do I have to start my website over with MySQL?
Additional Information
- All of the data on the site including the users is dummy data and not a big deal if it can't be preserved
- The main information I would like to preserve is the data structures, views, and roles as these have configured permissions for various content types and fields that would be tedious to replicate