Ghost 4.1.0 errored during boot

Hi, folks,

I’ve had a glitch on upgrading to 4.1.0. I got the following message.

Message: Ghost was able to start, but errored during boot with: alter table members_login_events add constraint members_login_events_member_id_foreign foreign key (member_id) references members (id) on delete CASCADE - UNKNOWN_CODE_PLEASE_REPORT: Referencing column ‘member_id’ and referenced column ‘id’ in foreign key constraint ‘members_login_events_member_id_foreign’ are incompatible.

Help: Error occurred while executing the following migration: 08-add-members-login-events-table.js

Here’s the system info.

OS: Ubuntu, v20.04.1 LTS
Node Version: v14.16.0
Ghost Version: 4.1.0
Ghost-CLI Version: 1.16.2

I’ve temporarily rolled back to the v3 so the site is still accessible. Any thoughts? (I didn’t access the log file before rolling back, which was a mistake, so if necessary, I can break it again to get hold of the logs).

Cheers, Will

I had the same problem. It was due to old database tables having a different UTF-8 collation (text encoding) to new tables, which was probably related to a MySQL update to version 8.x that happened when updating Ubuntu.

In my case I manually converted all the old tables to the new collation to fix it.

Great! Thanks. I’ll try that (and mark it as a solution if it works for me too). :slight_smile:

Hmm… it’s possibly not that. All tables in my ghost_production database have the same collation (utf8mb4_general_ci).

All tables in my ghost_production database have the same collation (utf8mb4_general_ci).

Did you recently upgrade to a newer version of MySQL? If so that might explain the issue - MySQL v8 changes the default table collation to something other than utf8mb4_general_ci, so any new tables that Ghost attempts to create as part of v4 migrations will be created with the new collation.

You should be able to check your database’s default charset/collation using the following query:

WHERE SCHEMA_NAME='ghost_production';

If the default charset/default collation are anything other than utf8mb4 and utf8mb4_general_ci, respectively, you’ll need to run the following command to update the defaults:

ALTER DATABASE `ghost_production`
DEFAULT COLLATE utf8mb4_general_ci;

Thanks for that. The default collation was out of sync. But after updating the defaults and running again, I got the same error. I’ll have another look tomorrow.
Cheers, Will

Okay. A fresh install did it. Not sure what the problem was, but Ghost v4 now working nicely!

I’m also getting this with the basic install on DigitalOcean. Haven’t had time to troubleshoot it, but running @acburdine’s sql commands still produced an error on startup, so there’s something else going on perhaps.