Upgrading to 6.6.x error

Hi,

I get the following error when I try to upgrade to 6.6.x (tried .0 thru .2, from 6.5.7) with the following error:

Executing script /Users/eddy/studio-projects/crm-revamp/modules/core/build/db/10-cuba/update/mysql/17/170502-createSessionHistoryTable.sql
Aug 29, 2017 9:55:40 PM groovy.sql.Sql execute
WARNING: Failed to execute: create table SEC_SESSION_LOG (
...
) because: Cannot add foreign key constraint
:app-core:updateDb FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app-core:updateDb'.
> java.sql.SQLException: Cannot add foreign key constraint

Any ideas what this could be?

Thanks,
Eddy

Hi,
As written in the error message, the “170502-createSessionHistoryTable.sql” script could not be executed for some reason. Is there anything in the log after “Cannot add foreign key constraint”?
I have tried to reproduce the problem, but in my environment, everything works well.
Which version of MySQL server do you use?
Try to workaround the problem:

  1. Find the script in the filesystem and execute it on your database using some DBMS manager.
  2. Register “10-cuba/update/mysql/17/170502-createSessionHistoryTable.sql” in the sys_db_changelog.

Did you specify custom Connection params in Studio?
One of our developers encountered the same problem today and found the probable reason: his database had Charset different from “UTF8”. As result, scripts with constraints could not be executed. The problem does not occur after “Charset” and “Collation name” properties were corrected. Please check this properties of your database.

I’m using MySQL v14.14 and have set it up with charset utf8, which is defined in the connection params. And also when the db was created.

Let me take a look at your suggestions around the scripts and I’m assuming you mean the correction of charset in the the script. Will let you know how it goes.

Thanks.

Great, it worked. I modified the script to create the table with charset utf8, ran it and updated the sys_db_changelog.

One quick question, what value should i be using for is_init in sys_db_changelog? I assumed and used a value of 1 which worked but not sure if that will affect anything.

Thanks for the help!

Hi,
Is_init is set to “1” when the script is executed during the database creation. It is set to “0” when the script is executed during the DB update (for instance the platform is upgraded to a newer version).
At the moment of writing the field is used just for information and does not affect anything.