Ghost-CLI
Ghost-CLI copied to clipboard
Incorrect Database Type Verification
Summary
I recently upgraded several ghost sites of mine from 4.x to 5.x and run into after sorting through other migration and database management issues related to the mysql 8 upgrades a config file schema validation that is failing.
Steps to Reproduce
- Upgrade a ghost 4.48.2 site to Ghost 5.11.0 (or any ghost release after https://github.com/TryGhost/Ghost/commit/bf6f607f424106c1973b09dd47f62c1b972b2ae6 was merged)
- Upon
ghost startyou will be faced with an error during1) Validating config
Log file
+ sudo systemctl is-active ghost_<sitename>-com
✔ Checking system Node.js version - found v16.13.2
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_<sitename>-com
✖ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.13.2
One or more errors occurred.
1) Validating config
Error detected in the production configuration.
Message: Invalid database type. Supported types are mysql and sqlite3
Configuration Key(s): database.client
Current Value(s): mysql2
Technical details
This is automatically output by Ghost-CLI if an error occurs, please copy & paste:
- OS: Ubuntu v20
- Node Version: v16.13.2
- Ghost Version: 5.11.0
- Ghost-CLI Version: 1.22.0
- Environment: production
- Command:
ghost start
Bug submission checklist
Please fill out this checklist to acknowledge that you followed the requirements to submit a bug report.
- [x] Tried to find help in the forum & docs
- [x] Checked for existing issues
- [x] Attached log file
- [x] Provided technical details incl. operating system
Workaround is to change mysql2 to mysql and reissue the ghost start command for the impacted site.
I'm looking at this issue and the related PR and I'm quite confused. How did your config come to contain mysql2?
In the PR desc you say:
The addition of the mysql2 client was done in a backwards compatible way, but the config.production.json change wasn't done in a compatible way with the ghost-cli.
In what way was it not compatible with ghost-cli?
The point of the change we made was that Ghost's underlying mysql client was changed from mysql to mysql2 as an implementation detail that is deliberately not exposed to config. You can't pick and choose between clients in Ghost, so the config should stay as mysql 🤔
I definitely didn't change it myself... so must have been done in migrating from an older version of ghost via the ghost-cli. The issue for me is that this change to the ~config.yaml~ config.production.json fails validation of any ghost command after the migration/upgrade (see earlier example and example from community forums -> https://forum.ghost.org/t/invalid-database-type-supported-types-are-mysql-and-sqlite3-current-value-s-mysql2/30740/3).
As I'm not too familiar with the ghost code itself, but rather the templating I'm a bit out of depth here. Though looking through the linked PR that added the mysql2 client I see a nconf.set(...) operation (see below screenshot) if there is a later yaml.print(nconf) well that is exactly how this is happening.
After the upgrade there were other modifications made to the config.production.yamlThere was another change that happened where I lost my earlier configured mail configuration and had to reset that up for all 5 of my Ghost self-hosted sites. I didn't modify the config.production.json myself so something in the upgrade script did this.
The nconf.set calls inside of Ghost just update the in-memory representation of the config to achieve the "implementation detail" of changing our client behind the scenes.
There is no place where we write back to the configuration JSON files in Ghost.
In Ghost CLI there are tools and migrations that can touch the config file, but there is nothing in the update command that I would expect to cause the outcome you're describing - neither the addition of mysql2 to the config, nor the modification of mail config.
Can you provide the exact steps you took to upgrade from 4 to 5?
ghost upgrade 🙂
I didn't even know about this mysql2 until this error happened which got me to dig down the rabbit hole to see where this would go.
Along my upgrade path I did have to wonder into the weeds to fix the collation issue that was due to the MySql version upgrade (not the client) -> https://forum.ghost.org/t/unable-to-upgrade-ghost-from-v4-2-0-to-v4-3-0-cascade-unknown-code-please-report/22086/56 helped get me to a solution... but it took some time to get there.
Our bot has automatically marked this issue as stale because there has not been any activity here in some time. The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR. We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂