Hi everyone,
I am attempting to upgrade OJS from 3.3.0-22 to 3.5.0-3. The process is consistently failing in the database migration stage. Each time I resolve one error and restart the upgrade, the script fails again because it doesn’t account for changes already made in the previous (failed) attempt.
Here is a chronological log of the errors encountered:
- Unique Index Conflicts (Duplicate Key 1061) The script repeatedly fails when trying to add unique indexes that were already created during partial runs. I’ve had to manually drop these to proceed:
genre_settings_unique
review_round_files_unique
event_log_settings_unique
announcement_settings_unique
category_settings_unique
oai_resumption_tokens_unique
- Foreign Key Constraint Blocks (#1828) The upgrade stopped because it couldn’t drop columns linked to foreign keys:
current_issue_id in journals (blocked by journals_current_issue_id_foreign)
context_id in announcement_types (blocked by announcement_types_context_id_foreign)
- Missing Columns during Data Migration (#1054) Later stages of the migration expected columns that were either already dropped or renamed:
Unknown column ‘i.current’ in ‘where clause’ during issue migration.
Unknown column ‘at.assoc_type’ in ‘where clause’ in announcement_types migration.
- Duplicate Columns and Drop Index Errors (#1060 & #1091)
Duplicate column name ‘context_id’ when the script tried to rename assoc_id.
Can’t DROP INDEX ‘announcement_types_assoc’; check that it exists – the script fails if the index was already removed.
Environment:
Source Version: OJS 3.3.0.22
Target Version: OJS 3.5.0.3
PHP Version: 8.2
DB: 10.4.32-MariaDB
It seems the migrations are not fully idempotent. I am currently stuck at the announcement_types foreign key constraint.
Has anyone else experienced this “loop” of manual database fixes during the 3.5 upgrade? Is there a recommended way to skip these checks or a master SQL script to prepare the 3.3 database for the 3.5 structure?
What I’ve tried so far:
To break out of the loop, I’ve been manually running a cleanup script to drop indexes that were causing the “Duplicate key” errors. I used SET FOREIGN_KEY_CHECKS = 0; to ensure the commands executed, but the upgrade eventually hits a new conflict or reverts to a previous state.
Here is the SQL I used to mitigate the index issues:
SQL
SET FOREIGN_KEY_CHECKS = 0;
– OAI, Categories, and basic repeaters
DROP INDEX IF EXISTS oai_resumption_tokens_unique ON oai_resumption_tokens;
DROP INDEX IF EXISTS category_settings_unique ON category_settings;
DROP INDEX IF EXISTS journal_settings_unique ON journal_settings;
DROP INDEX IF EXISTS author_settings_unique ON author_settings;
– SETTINGS tables (Main cause of the loop)
DROP INDEX IF EXISTS site_settings_unique ON site_settings;
DROP INDEX IF EXISTS user_settings_unique ON user_settings;
DROP INDEX IF EXISTS notification_settings_unique ON notification_settings;
DROP INDEX IF EXISTS plugin_settings_unique ON plugin_settings;
DROP INDEX IF EXISTS library_file_settings_unique ON library_file_settings;
DROP INDEX IF EXISTS submission_settings_unique ON submission_settings;
DROP INDEX IF EXISTS publication_settings_unique ON publication_settings;
DROP INDEX IF EXISTS genre_settings_unique ON genre_settings;
DROP INDEX IF EXISTS issue_settings_unique ON issue_settings;
DROP INDEX IF EXISTS navigation_menu_item_settings_unique ON navigation_menu_item_settings;
DROP INDEX IF EXISTS submission_file_settings_unique ON submission_file_settings;
– Announcement / Event / Scheduler
DROP INDEX IF EXISTS announcement_settings_unique ON announcement_settings;
DROP INDEX IF EXISTS announcement_type_settings_unique ON announcement_type_settings;
DROP INDEX IF EXISTS event_log_settings_unique ON event_log_settings;
DROP INDEX IF EXISTS scheduled_tasks_unique ON scheduled_tasks;
– Email Templates
DROP INDEX IF EXISTS email_templates_default_data_unique ON email_templates_default_data;
DROP INDEX IF EXISTS email_templates_settings_unique ON email_templates_settings;
– Reviews and Workflow
DROP INDEX IF EXISTS review_round_files_unique ON review_round_files;
DROP INDEX IF EXISTS review_files_unique ON review_files;
DROP INDEX IF EXISTS review_form_responses_unique ON review_form_responses;
DROP INDEX IF EXISTS review_form_settings_unique ON review_form_settings;
DROP INDEX IF EXISTS review_form_element_settings_unique ON review_form_element_settings;
– Versions and others
DROP INDEX IF EXISTS versions_unique ON versions;
DROP INDEX IF EXISTS citation_settings_unique ON citation_settings;
DROP INDEX IF EXISTS filter_settings_unique ON filter_settings;
DROP INDEX IF EXISTS user_group_settings_unique ON user_group_settings;
SET FOREIGN_KEY_CHECKS = 1;
Despite this manual intervention, the upgrade script eventually triggers new errors (like the Foreign Key and Missing Column issues mentioned above), forcing me back into the loop. It appears the migration logic is not checking for the existence of these constraints before attempting to recreate them.
Thanks in advance for any help!