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:
- Reset your code base to the Drupal 9.3 or older version. The version that was used to create the config data
- Import your config data
- Execute all Drupal updates
- Export your config data
- Commit the changed config data
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
Comment #2
greg boggsUpgrading 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: 0and 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:
Comment #3
acbramley commentedI 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:
This is the full output of step 2 and 3:
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_9401which 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-clearfrom the updb call and the export worked as expected.Comment #4
greg boggsIncase it's important, my deploy process uses drush deploy which runs this:
Comment #5
acbramley commented@Greg Boggs the issue isn't in the deploy, but in whatever process updated/exported the config beforehand. See my updated comment in #3
Comment #6
greg boggsYes, 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...
Comment #7
greg boggsFor 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.
Comment #8
acbramley commentedThere 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.
Comment #9
greg boggsI'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:
Comment #10
alexpottAfter 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:
On Prod
Comment #11
catch@gregboggs the 'Updating Drupal core' page has this:
https://www.drupal.org/docs/updating-drupal/updating-drupal-core-via-com...
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.
Comment #12
superfluousapostrophe commentedI 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.
Comment #13
xjmComment #14
xjmComment #15
xjmComment #16
greg boggsThanks 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
Comment #17
xjmOK yeah, this isn't a bug, this is essentially overwriting the data with an out-of-date backup.
Comment #18
samuel.mortensonWhile 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.
Comment #19
greg boggsI've updated my comment at the top to add the tome database example.
~G
Comment #20
daffie commentedThe 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".
Comment #21
daffie commentedComment #22
alexpottI 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
Comment #23
acbramley commented@alexpott made some small typo tweaks but otherwise reads well!
Comment #24
colanMoved 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)?