Careless Ghost update bricked my installation

If you’re looking for some help, it’s important to provide as much context as possible so that people are able to assist you. Try to always mention:

  • What’s your URL? This is the easiest way for others to debug your issue
  • What version of Ghost are you using?
  • What configuration?
  • What browser?
  • What errors or information do you see in the console?
  • What steps could someone else take to reproduce the issue you’re having?

What’s your URL?

www.thelawbug.com

What version of Ghost are you using?

Last known was to be 3.42.4, Ghost reports current version as 4.1.2

What configuration?

Standard configuration except for some tweaks to the nginx config to make a few redirects. I can share nginx config if needed.

What browser?

Any. I’m facing this on mozilla firefox but this isn’t a browser issue.

What errors or information do you see in the console?

A lot of it. however, I suppose the relevant info is in the attached log. I tried updating ghost as usual. it said there was a version upgrade. I didn’t give much thought and followed the presented steps but seems like something failed along the process and looks like one of the tables in the database didn’t migrate fully which is causing the problem.

What steps could someone else take to reproduce the issue you’re having?

Not sure, I just simply run the command ghost update and that’s what caused it.

LOG:

Debug Information:
    OS: Ubuntu, v20.04.2 LTS
    Node Version: v14.16.0
    Ghost Version: 4.1.2
    Ghost-CLI Version: 1.16.3
    Environment: production
    Command: 'ghost start'
Message: Ghost was able to start, but errored during boot with: alter table `members_payment_events` add constraint `members_payment_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_payment_events_member_id_foreign' are incompatible.
Help: Error occurred while executing the following migration: 13-add-members-payment-events-table.js
Suggestion: journalctl -u ghost_www-iambandana-com -n 50
Stack: Error: Ghost was able to start, but errored during boot with: alter table `members_payment_events` add constraint `members_payment_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_payment_events_member_id_foreign' are incompatible.
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:53:28)
    at Object.onceWrapper (events.js:421:28)
    at Server.emit (events.js:315:20)
    at emitCloseNT (net.js:1659:8)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)

any advice and help in getting this recovered will be really helpful. I don’t have any backup of the ghost installation so I can not revert back :frowning: :slightly_frowning_face:

Same issue here on Ubuntu 20.04. Apparently it was due to a DB upgrade a while back.

The fix is to update the collation on those columns so they match the DB defaults. For me I ran the following (after connecting to mysql and selecting the Ghost DB)

alter table members_subscribe_events modify id varchar(24) character set utf8mb4 collate utf8mb4_general_ci;
alter table members_subscribe_events modify member_id varchar(24) character set utf8mb4 collate utf8mb4_general_ci;
alter table members_subscribe_events modify source varchar(50) character set utf8mb4 collate utf8mb4_general_ci;

After that I started ghost and it applied the remainder of the migrations. Your error is basically the same as mine but I can’t remember why I picked on the members_subscribe_events table tbh. Before making any changes check the collation of the tables by running:

show full columns from members_subscribe_events;

For me this showed utf8mb4_0900_ai_ci, which you should update to match your DB collation.

Also configure backups!

1 Like

Thanks a ton for the help, This really saved me!