I was trying to restore my OJS database from a backup and it did not work. Whenever I run php tools/upgrade.php in my terminal inside my OJS directory(I have confirmed I am running the command from the right directory), I get no output.
Steps I took leading up to the issue
I was in the process of upgrading from OJS 3.4.0-4 to OJS 3.5.0-1 and ended up having issues. I decided to try to start the process again so I reverted my OJS code back to version 3.4 and wanted to do the same to my database.
In order to do this, I logged into phpMyAdmin, selected my database and tried to drop all of the tables in my database. I could not successfully do this because of foreign key constraints, so after I selected all the tables and clicked âdropâ, there were still 9 tables remaining.
I went ahead and imported the database from my backup file which I acquired using a mysqldump before starting the entire upgrade process. After the data had imported from my backup file, I went back to the command line and tried running php tools/upgrade.php in the appropriate directory but I got an error saying: âCould not open input file: tools/upgrade.phpâ.
Seeing this, I closed my terminal and opened it again and when I ran php tools/upgrade.php again, it simply gave me no output. Please where did I go wrong with restoring my database and what is the proper procedure?
It sounds like there are a few things happening â but as far as getting the database restored from backup, Iâd recommend fully dropping and re-creating the database rather than trying to drop all tables inside it. You might check the phpMyAdmin documentation for more material on that.
Regards,
Alec Smecher
Public Knowledge Project Team
I was able to properly restore the database, but I still get no output when I run php tools/upgrade.php.
I checked the error log and ran into a couple of errors:
1.) Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (devlib_ojsdb.navigation_menus, CONSTRAINT navigation_menus_context_id FOREIGN KEY (context_id) REFERENCES journals (journal_id) ON DELETE CASCADE) (SQL: INSERT INTO navigation_menus (title, area_name, context_id) VALUES (User Navigation Menu, user, 0)) in /home/devlib/dev.ojs.lib.umassd.edu/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
2.) thrown in /home/devlib/dev.ojs.lib.umassd.edu/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 760
[01-Aug-2025 19:23:35 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table âdevlib_ojsdb.versionsâ doesnât exist in /home/devlib/dev.ojs.lib.umassd.edu/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php:444
I think there are still a few things happening here, so letâs try to pick them off one at a time.
Cannot add or update a child row: a foreign key constraint fails (devlib_ojsdb.navigation_menus, CONSTRAINT navigation_menus_context_id FOREIGN KEY (context_id) REFERENCES journals (journal_id) ON DELETE CASCADE)
I think this is probably caused by your database containing MyISAM tables. Starting with OJS 3.4.0, OJS requires all tables to use InnoDB (and this is the default for supported MySQL releases). Check your database dump to see if it contains any references to MyISAM; this is more of a database administration issue than an OJS issue, so you might find more resources on e.g. StackOverflow.
PHP Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table âdevlib_ojsdb.versionsâ doesnât exist
Iâm not sure what would cause this, especially after the last message, except for attempting to run an upgrade on an empty database. Make sure your database is properly loaded from backup, and that your config.inc.php is configured correctly in the [database] section.
Regards,
Alec Smecher
Public Knowledge Project Team
Thanks a lot. I checked my tables and found that some of them were MyISAM tables so I converted them to InnoDB and that seems to have solved the first issue. php tools/upgrade.php now works the way it is supposed to. I was updating from OJS 3.4.0 to 3.5.0. My database and code are back to version 3.4.0 but when I try to visit my OJS site, I get a HTTP 404 Error saying âFile not found.â I am also still getting the second error:
and it is saying the same thing for jobs table even though I can see that they are present in my database.
I can only guess that you are looking at a different database than OJS is looking at. Double-check that youâre examining the same database that is configured in config.inc.php, and that jobs and versions really are present there.
Regards,
Alec Smecher
Public Knowledge Project Team