Problem Upgrading from OJS. 3.2.1-4 to OJS 3.3.0-10: Foreign key constraint is incorrectly formed

Hello!

I am facing the problem of:: errno: 150 “Foreign key constraint is incorrectly formed” while upgrading from OJS. 3.2.1-4 to OJS 3.3.0-10

As I read, we have to change the engine type in all tables of the DB. (InnoDB)
Done.

I have also read that I have to include the line:
'engine' => 'InnoDB'
in the ojs-3.3.0-10/lib/pkp/classes/core/PKPApplication.inc.php file below the driver.

I have two doubts:
1.- Is it necessary to make the change in both places (DB and File)?
2.- If the answer to the first question is yes, then, would this code be correct? (I don’t know PHP):

210                 $capsule->addConnection([
211                         'driver'    => $driver,

newline **’engine’ => ‘InnoDB’`,
212 ‘host’ => Config::getVar(‘database’, ‘host’),
213 ‘database’ => Config::getVar(‘database’, ‘name’),
214 ‘username’ => Config::getVar(‘database’, ‘username’),
215 ‘port’ => Config::getVar(‘database’, ‘port’),
216 ‘unix_socket’=> Config::getVar(‘database’, ‘unix_socket’),
217 ‘password’ => Config::getVar(‘database’, ‘password’),
218 ‘charset’ => Config::getVar(‘i18n’, ‘connection_charset’, ‘utf8’),
219 ‘collation’ => Config::getVar(‘database’, ‘collation’, ‘utf8_general_ci’),
220 ]);

Thanks in advance!
Cristina

ps: Everybody here knows that any change implied a lot of work if it fails…

Hello @lacris,

You may want to take a look at some of the posts that report on this error during the upgrade process: “https://forum.pkp.sfu.ca/search?q=“Foreign%20key%20constraint%20is%20incorrectly%20formed”%20upgrade

-Roger
PKP Team

Good morning rcgillis,

Hello,

Before asking, I had already read those “posts” and that is why I was asking since it is not clear to me if I have to make both changes or just change in the DB tables.

There are “Post” that only talk about changing the engine in the DB, others talk about changing in the file and my main question is if the change has to be done in both places.

As any error that occurs implies a tedious and long backtracking (we have many magazines) I wanted to play it safe.

I’m going to change the value in both places and try.
I cross my fingers!
Thanks.

Hi @lacris,

You need to change the default storage engine in the DB, which ensures that when the new table is created, it will use InnoDB; and make the change for every table that is already created. I suggest checking the DB documentation regarding the procedure, e.g.: MySQL :: MySQL 8.0 Reference Manual :: 16.1 Setting the Storage Engine. There is no need to change OJS source code.

Hi! @rcgillis
I have a doubt, I did the same type of migration and in the end it gave me this:
PHP Notice: Trying to get property ‘primary_locale’ of non-object in /opt/revistas/lib/pkp/classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php on line 665

I Good morning to all!

I was finally able to perform the update: I changed the type of engine in the MySQL tables and in the ojs-3.3.0-10/lib/pkp/classes/core/PKPApplication.inc.php file I also added the engine type to make sure it went well and it ended well!

209                 $capsule = new Capsule;
210                 $capsule->addConnection([
211                         'driver'    => $driver,
**212                         'engine'    => 'InnoDB',**
213                         'host'      => Config::getVar('database', 'host'),
214                         'database'  => Config::getVar('database', 'name'),
215                         'username'  => Config::getVar('database', 'username'),
216                         'port'      => Config::getVar('database', 'port'),
217                         'unix_socket'=> Config::getVar('database', 'unix_socket'),
218                         'password'  => Config::getVar('database', 'password'),
219                         'charset'   => Config::getVar('i18n', 'connection_charset', 'utf8'),
220                         'collation' => Config::getVar('database', 'collation', 'utf8_general_ci'),
221                 ]);

Thank you all for your help!
Cristina