Problem/Motivation

Importing older config without the mysql/pgsql module enabled will generate error:
The following reasons prevent the modules from being uninstalled: The module 'MySQL' is providing the database driver 'mysql'.
When viewing config differences, it is showingit shows that I'm removing mysql: 0 in core extensions. If I add mysql: 0 to my core extensions file, everything works normally.

The error is the result of #3129043: Move core database drivers to modules of their own.

Proposed resolution

You get this error, because you are importing config data that is made on a Drupal 9.3 or older site. To fix this you need to do:

  1. Reset your code base to the Drupal 9.3 or older version. The version that was used to create the config data
  2. Import your config data
  3. Execute all Drupal updates
  4. Export your config data
  5. Commit the changed config data

agaric.coop blog post

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

The bug was originally reported by @Greg Boggs (#3129043-156: Move core database drivers to modules of their own).

Comments

daffie created an issue. See original summary.

greg boggs’s picture

Upgrading from 9.3 to 9.4 gave me this message:

The current database driver is provided by the module: /mysql/. The module is
W: > currently not enabled. You should immediately enable [1] the module.

To fix this, I manually edited my sync/core.extensions.yml file to add:

mysql: 0

and then I ran a config import.

I'm guessing you could probably also enable this module in Drupal 9.3, then run the upgrade.

For Tome, I would use:

sqlite: 0
acbramley’s picture

I got this on one of 3 projects updating from 9.3.16 to 9.4.0 this morning. All followed the exact same process, but for some reason one of them didn't export the updated core.extension.yml. I had to manually edit the yml file as per #2 and then run a config import.

Process was:

  1. composer update
  2. drush updb -y
  3. drush cex

This is the full output of step 2 and 3:

$ make updb
./bin/drush -r /data/app updatedb --no-cache-clear -y
 -------- ------------------- ------------- ----------------------------------
  Module   Update ID           Type          Description
 -------- ------------------- ------------- ----------------------------------
  image    image_loading_att   post-update   Add the image loading attribute
           ribute                            setting to image field formatter
                                             instances.
  system   enable_provider_d   post-update   Enable the modules that are
           atabase_driver                    providing the listed database
                                             drivers.
  update   add_view_update_n   post-update   Add 'view update notifications'
           otifications_perm                 to roles with 'administer site
           ission                            configuration'.
  views    image_lazy_load     post-update   Add lazy load options to all
                                             image type field configurations.
  views    provide_revision_   post-update   Clear caches due to adding a
           table_relationshi                 relationship from revision table
           p                                 to base table.
 -------- ------------------- ------------- ----------------------------------


 // Do you wish to run the specified pending updates?: yes.

>  [notice] Update started: image_post_update_image_loading_attribute
>  [notice] Update completed: image_post_update_image_loading_attribute
>  [notice] Update started: system_post_update_enable_provider_database_driver
> [2022-06-16T00:10:31.497078+00:00] system.INFO: mysql module installed. [] {"referer":"","ip":"127.0.0.1","request_uri":"http://127.0.0.1:8080/","uid":0,"user":""}
>  [notice] Update completed: system_post_update_enable_provider_database_driver
>  [notice] Update started: update_post_update_add_view_update_notifications_permission
>  [notice] Update completed: update_post_update_add_view_update_notifications_permission
>  [notice] Update started: views_post_update_image_lazy_load
>  [notice] Update completed: views_post_update_image_lazy_load
>  [notice] Update started: views_post_update_provide_revision_table_relationship
>  [notice] Update completed: views_post_update_provide_revision_table_relationship
 [success] Finished performing updates.
$ make cex
./bin/drush -r /data/app config-export -y
 [notice] Differences of the active config to the export directory:
+------------+----------------------------------------------------+-----------+
| Collection | Config                                             | Operation |
+------------+----------------------------------------------------+-----------+
|            | core.entity_view_display.media.image.default       | Update    |
|            | core.entity_view_display.media.image.media_library | Update    |
+------------+----------------------------------------------------+-----------+

On the 2 other projects, core.extension was properly updated. All 3 projects are using config_ignore module.

Worth noting that this may be a cache thing, my other projects ran jsonapi_update_9401 which made config changes which could have cleared some config cache required to export the new modules?

EDIT: Confirmed cache clear is the issue. I removed the --no-cache-clear from the updb call and the export worked as expected.

greg boggs’s picture

Incase it's important, my deploy process uses drush deploy which runs this:

drush updatedb --no-cache-clear
drush cache:rebuild
drush config:import
drush cache:rebuild
drush deploy:hook
acbramley’s picture

@Greg Boggs the issue isn't in the deploy, but in whatever process updated/exported the config beforehand. See my updated comment in #3

greg boggs’s picture

Yes, it sounds like your issue may be slightly different than mine. There's no export in my upgrade process, only a drush deploy, which is required on all my code pushes to production. And, I didn't have any issues exporting after I got the drush deploy to work.

So, it sounds like there may be a special step required to upgrade to Drupal 9.4 with configuration exporting/importing that isn't on this page:

https://www.drupal.org/docs/updating-drupal/updating-drupal-core-via-com...

greg boggs’s picture

For my issue, I imagine the answer is that folks need to first update to 9.3 latest version, then enable the mysql module, then upgrade to Drupal 9.4. For yours, it sounds like the process needs an extra cache clear added.

acbramley’s picture

There's no export in my upgrade process

There should always be an export in the process? Database updates are constantly updating config and that needs to be exported, otherwise your schema will be out of date.

greg boggs’s picture

I'm following the directions provided on the updating Drupal core page which admittedly are a bit thin when it comes to config. If configuration needs to change during an update, my expectation is that it's handled by updb, or if we are depending on users manually exporting configuration during updates that new versions check to see if that's been done.

Maybe something like this is needed to upgrade to drupal 9.4:

composer require drupal/core-recommended:~9.3 --with-all-dependencies
drush cr
drush cex -y
drush en mysql -y
drush cex -y
(Deploy to production)
drush deploy (on production)

composer update "drupal/core-*" --with-all-dependencies
drush cr
drush cex -y
(deploy to production)
drush deploy (on production)
alexpott’s picture

After updating you need to export your configuration. You should never ever import config that is has not been exported from the current codebase. This is a workflow error. Perhaps this will finally be the impetus we need to land #2762235: Ensure that ConfigImport is taking place without outstanding updates and #2628144: Ensure that ConfigImport is taking place against the same code base. The workflow has to be:

On dev:

  1. Install your site as it is in prod (in this case on D9.3)
  2. Run the updates (do not use Drush deploy - that does the wrong thing)
  3. Export config config
  4. Commit changes

On Prod

  1. Deploy code from the commit (including changes due to composer.lock change - however you do that - running composer install / update in prod is not the best way)
  2. Run drush deploy
catch’s picture

@gregboggs the 'Updating Drupal core' page has this:

https://www.drupal.org/docs/updating-drupal/updating-drupal-core-via-com...

If you are using config management to deploy your config, make sure to export the config with drush config:export after the database update because some core updates may change the structure of the config files or introduce new values to them. Add the option --diff to view actual changes.

If there's a page missing we should add it.

I think we should probably mark this issue duplicate of the two issues in #10.

superfluousapostrophe’s picture

I wanted to note that I encountered this error as well. In my case, my deployment process uses a tagged version of the config which is imported after DB updates. The error occurred when my script saw differences between the current 9.4.0 config and the tagged 9.3.9 config that composer pulled in during the build.

To fix my situation, I ran the upgrade locally, exported and tagged the updated config. I then updated the site's composer.json to use the new tag. Deployment worked after that.

xjm’s picture

Issue tags: +9.4.0 update
xjm’s picture

Title: Importing older config without the mysql/pgsql module enabled will generate error » [regressopn] Importing older config without the mysql/pgsql module enabled will generate error
xjm’s picture

Title: [regressopn] Importing older config without the mysql/pgsql module enabled will generate error » [regression] Importing older config without the mysql/pgsql module enabled will generate error
greg boggs’s picture

Thanks for clarifying the process. This is awesome.

We could add the config export step to the updating page between run database updates section and the update the production environment section

xjm’s picture

Title: [regression] Importing older config without the mysql/pgsql module enabled will generate error » Importing older config without the mysql/pgsql module enabled will generate error
Category: Bug report » Support request

OK yeah, this isn't a bug, this is essentially overwriting the data with an out-of-date backup.

samuel.mortenson’s picture

While Tome isn't a core project, this does effectively mean all Tome sites that run "composer update" before installing their site will have to manually add "sqlite" as a module dependency in core.extension.yml. I've documented the correct upgrade guide for users (drush tome:install, composer require, drush updb, git commit...) but users rarely read docs. Mostly commenting in case other Tome users need to find this.

greg boggs’s picture

I've updated my comment at the top to add the tome database example.

~G

daffie’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

The problem from the issue summary is the result of the wrong way of importing config data.
I have updated the issue summary with how to fix your problem. Thank @alexpott for the solution.
Marking this issue as "works as designed".

daffie’s picture

Issue summary: View changes
alexpott’s picture

I wrote something down and hopefully put it in a useful place in the docs... Needs to be added by guide maintainers but if people on this issue could review / contribute that would be super handy - https://www.drupal.org/docs/updating-drupal/drupal-updates-and-deployments

acbramley’s picture

@alexpott made some small typo tweaks but otherwise reads well!

colan’s picture

Moved to #2628144-61: Ensure that ConfigImport is taking place against the same code base...

Just coming across this now, as someone else pointed me here for a very different reason, which is really just another side effect of the same problem (but would need a different solution to prevent foot-shooting):

The process for one of my current projects, when I found it, was to run `drush deploy` in the dev environment (after cloning DB & files from Prod), and then import config. If all went well, we'd do this on Prod. A little while ago, I noticed that upstream config was missing even though the DB schemas were up-to-date.

What I eventually discovered was that new config was generated, but was then being overwritten as discussed in #17. I then rewrote the process to match the new doc generated here. So thanks for confirming that I did this correctly as it's exactly what I developed on my own.

The difference in my case is that you never get any errors, but you'll eventually discover that you're missing config even though your DB schema is up-to-date. Would it be possible to prevent running `drush config:import` if it would be overwriting older config?

To do this, I think we'd need something like #2628144: Ensure that ConfigImport is taking place against the same code base, but for config: Version or timestamp each config file so that when you try to overwrite, the system can stop you from "overwriting the data with an out-of-date backup". Is that what #2428045: Comparing active storage to install storage is problematic, install storage may change anytime is for, would we need a separate issue for this, or should we just drop it as it would be too much work to detect (and have folks jump through the same hoops I did)?