Error when trying to add multi reference field to table

Dear all,

I get the following error message when I am trying to add a multi-reference field to a table.

Error: alter table ‘training_attendees’ ass constraint ‘training_attendees_training_id_foreign’ foreign key ('training_id) references ‘training’(‘id’) on update CASCA on delete CASCADE - ER_CANNOT_ADD_FOREIGN: Cannot add foreign key constraint.

PS: Is there a way to copy the content of the error message in Wappler? I tried to copy the text from the dialog box Data Base Update Failed, but it was not possible. I think it would be very helpful to be able to copy the error messages.

I have two tables - one table training with the Primary Key ‘id’ the data type is int(11). This table includes also data fields for the name, start and end-date and a reference to the training provider. I now wanted to work with the multi reference functionality to assign multiple employees to a training. Employee information is stored in the table employee, also with a primary key ‘id’ with the data type int(11).

When I open my database outside the database manager in Wappler I see that Wappler despite the error message created a new table called ‘training_attendees’ with two columns. ‘training_id’ and ‘employee_id’. However, both have a data type of int(10) unsigned. Might this be the problem when the program tries to create the foreign key as the primary keys have the data type int(11) and Wappler now creates the multi reference table with int(10) unsigned?

What can I do to solve the problem?

I appreciate your help.

Thank you very much

I confronted a similar issue yesterday.
I’ve understood what causes the problem, so I decided to share.

When you make relations between tables, foreign key of one table and the primary key of another must have identical parameters. By that, I mean type, charset and signed/unsigned attribute.

When I initially created the database for my project, I did it outside the Wappler, using another tool. So main table doesn’t have an UNSIGNED attribute. (maybe, my fault)
But when I tried to create a new table with reference using Wappler Database Manager, it seems like it always puts UNSIGNED for foreign keys (which is reasonable).
That’s why those two tables not compatible.

So it is not a bug.
Just seems like it is better to use the same tool for managing databases during all project’s lifecycle.
For all new projects I’m using only Wappler Database for this purpose, so there is no problem.