Migration Error - Upgrading Ghost from 3.x to 5.x

I am very behind on updating my ghost instance and started the process to update from version 3.0.2 (Mysql 5.7.38) to version 5.2.3. While I worked through that update, I had to run ghost update v3 before being able to update to 5.2.3 and along the way updated my node. I have successfully updated to 5.2.3, but when restarting my ghost instance (ghost restart) I received a migration error.

What is strange about this migration error is that it suggests running ghost update v3, which doesn’t make sense because I’m on 5.2.3. Following the second suggestion, I ran journalctl -u ghost_www-website-com -n 50 and saw a more verbose debug that pointed to the location of knex-migrator error, but no valuable information to work off of. I have seen some similar debug questions in the forum where it might have to do with collation name in the DB, but I’m not sure if that is the case for me.

Any direction would be helpful!

Error:

Debug Information:
    OS: Ubuntu, v18.04.3 LTS
    Node Version: v16.15.1
    Ghost Version: 5.2.3
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'
Message: Ghost was able to start, but errored during boot with: Unable to run migrations
Help: Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest.
Suggestion: journalctl -u ghost_www-website-com -n 50
Stack: Error: Ghost was able to start, but errored during boot with: Unable to run migrations
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:73:28)
    at Object.onceWrapper (node:events:641:28)
    at Server.emit (node:events:527:28)
    at emitCloseNT (node:net:1728:8)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

journalctl -u ghost_www-website-com -n 50

    Unable to run migrations
Jun 28 12:42:08 website-com node[19796]: "You must be on the latest v3.x to update across major versions - https://ghost.org/docs/update/"
Jun 28 12:42:08 website-com node[19796]: "Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest."
Jun 28 12:42:08 website-com node[19796]: Error ID:
Jun 28 12:42:08 website-com node[19796]:     b95aac70-f6df-11ec-9c81-5572693a5f7d
Jun 28 12:42:08 website-com node[19796]: ----------------------------------------
Jun 28 12:42:08 website-com node[19796]: InternalServerError: Unable to run migrations
Jun 28 12:42:08 website-com node[19796]:     at /var/www/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:1032:19
Jun 28 12:42:08 website-com node[19796]:     at up (/var/www/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:118:19)
Jun 28 12:42:08 website-com node[19796]:     at Object.up (/var/www/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:54:19)
Jun 28 12:42:08 website-com node[19796]:     at /var/www/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:982:33
Jun 28 12:42:08 website-com node[19796]:     at /var/www/ghost/versions/5.2.3/node_modules/knex/lib/execution/transaction.js:221:22
Jun 28 12:42:08 website-com node[19796]:     at processTicksAndRejections (node:internal/process/task_queues:96:5)

Did you update MySQL 5 first? You need to install MySQL 8 before updating to Ghost V5.

What’s the output from ghost ls?

1 Like

Originally that was my issue, but I was able to upgrade to MySQL 8 and re-ran hoping to see some success, but left with the same issue and errors at the migration

ghost ls outputs:

β”‚ Name                   β”‚ Location       β”‚ Version β”‚ Status  β”‚ URL β”‚ Port β”‚ Process Manager β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ www-website-com        β”‚ /var/www/ghost β”‚ 5.2.3   β”‚ stopped β”‚ n/a β”‚ n/a  β”‚ n/a             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

I ran ghost doctor:

βœ” Checking system Node.js version - found v16.15.1
βœ” Checking logged in user
βœ” Ensuring user is not logged in as ghost user
βœ” Checking if logged in user is directory owner
βœ” Checking current folder permissions
βœ” Checking system compatibility
βœ” Checking for a MySQL installation
+ sudo systemctl is-active ghost_www-connorphillips-com
βœ” Validating config
βœ” Checking folder permissions
βœ” Checking file permissions
βœ” Checking content folder ownership
βœ” Checking memory availability
βœ” Checking binary dependencies
βœ” Checking free space
βœ” Checking systemd unit file
βœ” Checking systemd node version - found v16.15.1

Then ghost migrate:

ghost migrate

βœ” Checking for available migrations
No migrations needed :)

Finally ghost restart:

+ sudo systemctl is-active ghost_www-website-com
Ghost instance is not running! Starting...
+ sudo systemctl start ghost_www-website-com
+ sudo systemctl stop ghost_www-website-com
βœ– Starting Ghost
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Unable to run migrations
Help: Run 'ghost update v3' to get the latest v3.x version, then run 'ghost update' to get to the latest.
Suggestion: journalctl -u ghost_www-website-com -n 50

Debug Information:
    OS: Ubuntu, v18.04.3 LTS
    Node Version: v16.15.1
    Ghost Version: 5.2.3
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'

mysql --version:

mysql Ver 8.0.29 for Linux on x86_64 (MySQL Community Server - GPL)

Maybe it has to do with the character set and collation name?

mysql> SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='ghost_production';
+----------------------------+------------------------+
| DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+----------------------------+------------------------+
| latin1                     | latin1_swedish_ci      |
+----------------------------+------------------------+
1 row in set (0.00 sec)

Update:

I updated the values based on the forum responses to issues, but still seeing the same migration issues

mysql> SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='ghost_production';
+----------------------------+------------------------+
| DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME |
+----------------------------+------------------------+
| utf8mb4                    | utf8mb4_general_ci     |
+----------------------------+------------------------+
1 row in set (0.01 sec)

I’ve started to follow the instructions to update to v3 before updating to v5.

Message: Unable to update Ghost directly to v3.42.9. You must be on the latest v5.x to update across major versions.
Help: Run "ghost update v5" to get the latest v5.x version, then run "ghost update" to get to v3.

It doesn’t make sense that I’m updating to v5, to update to v3, to update back to v5. Is it possible to install 3.42.9 while keeping 5.x? Or instructions to revert to 3.42.9 before going through the update process again?

Did you roll-back or restore a backup before starting over? If you have a mix of incompatible software versions, you’re going to run into difficulties.

I recommend you roll-back to the working V3 instances, and then follow the upgrade steps from the official documentation previously linked.

1 Like

Yes I missed that in the documentation and had to start from an old snapshot and was able to bypass this issue. Currently facing migration issues at the last step, but I think that this question has been answered. Thank you!

1 Like

I’m having this same issue. Did you ever get a resolution? My MySql was on v8 before I started the upgrade.

@tharris, please start a new thread in #help:self-hosting, and explain the problem and your hosting environment.

I had similar issues in the past related to incomplete migration.
In my case they were related to the DB.

I was able to solve them by forcing installation of older version:

Force update

If an update fails you can start by forcing a retry to attempt the upgrade a second time.

ghost update --force

Rollback

If something goes wrong, you can always revert to the previous stable version of Ghost.

ghost update --rollback

There was difference in the table structure which was solved after:

  • ghost 3 β†’ ghost 3 max
  • ghost 4 β†’ ghost 4 max
  • ghost 5