Multiple errors while upgrading from 3.4.0-5 to 3.5.0-1

Hello,

While upgrading from 3.4.0-5 to 3.5.0-1, I am getting the following errors.

Earlier we had 3 journals in a single OJS installation. Later we have separated with own OJS installation. Now in the installation journal 3 exists, not 1 and 2.

ERROR: Upgrade failed: DB: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (jour_ojs667.invitations, CONSTRAINT invitations_context_id FOREIGN KEY (context_id) REFERENCES journals (journal_id) ON DELETE CASCADE) (Connection: mysql, SQL: insert into invitations (type, user_id, context_id, email, inviter_id, status, payload, updated_at, created_at) values (reviewerAccess, 27, 2, ?, ?, INITIALIZED, {“reviewAssignmentId”:null}, 2025-10-02 05:43:46, 2025-10-02 05:43:46))

Upgrade failed: DB: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘context’ in ‘notification_subscription_settings’ (Connection: mysql, SQL: alter table notification_subscription_settings modify context bigint null)

Upgrade failed: DB: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘redirect’ in ‘site’ (Connection: mysql, SQL: alter table site modify redirect bigint null)

ERROR: Upgrade failed: DB: SQLSTATE[HY000]: General error: 1005 Can’t create table jour_ojs667.filters (errno: 121 “Duplicate key on write or update”) (Connection: mysql, SQL: alter table filters add constraint filters_parent_filter_id foreign key (parent_filter_id) references filters (filter_id) on delete cascade)

Kindly guide to upgrade successfully.

Hi @Psek,

Walking through these one at a time. Make sure you have a good backup before working with the database directly!

ERROR: Upgrade failed: DB: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (jour_ojs667.invitations, CONSTRAINT invitations_context_id FOREIGN KEY (context_id) REFERENCES journals (journal_id) ON DELETE CASCADE) (Connection: mysql, SQL: insert into invitations (type, user_id, context_id, email, inviter_id, status, payload, updated_at, created_at) values (reviewerAccess, 27, 2, ?, ?, INITIALIZED, {“reviewAssignmentId”:null}, 2025-10-02 05:43:46, 2025-10-02 05:43:46))

This is caused by left-over data after the removal of the other contexts. You should be able to resolve it by removing this data before running the upgrade script:

DELETE FROM access_keys WHERE context IN (1, 2);

Upgrade failed: DB: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘context’ in ‘notification_subscription_settings’ (Connection: mysql, SQL: alter table notification_subscription_settings modify context bigint null)

Upgrade failed: DB: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘redirect’ in ‘site’ (Connection: mysql, SQL: alter table site modify redirect bigint null)

I think these two are caused by attempting to re-run an upgrade after one has already failed. Before you can attempt an upgrade again, make sure you restore your installation from backup taken before the first upgrade attempt.

The third error might go away with the above solution(s) – if not, let’s come to it again.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

Thank you for your guidance. It worked.

1 Like

This topic was automatically closed after 9 days. New replies are no longer allowed.