Hello CakePHP community!
My Problem
Since some weeks a problem with my migrations appeared.
About three months ago I created the initial migrations file.
Now when I try to set up a new developing environment and execute the initial migration I get the error:
errno: 150 “Foreign key constraint is incorrectly formed”
The “id” columns were created automatically and not manually defined in the migrations file.
In my initial migration file the column I want to create an foreign key on has the data type “int(11)”.
In older developing environments all “id” columns have the data type “int(11)”
In new developing environments all “id” columns have the data type “int(11) unsigned”.
So the data types in new developing environments do not macht.
This is the reason why the migration fails.
It seems like suddenly the “id” column in my database have different default values on newer systems.
Here on an older developing Environment:
MariaDB [user_service_test]> describe dummytable;
+-------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
And here on a new one:
MariaDB [newsletter_service_test]> describe dummytable;
+-------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
My question (s)
Who is responsible for the data type of the “id” column?
Is it somewhere in the plugins? Or the MySQL adapter? …the PDO driver?
Can somebody provide me with some information how I can solve this problem without changing the data type of the columns in the database?
Some information on my environments.
Via composer the following versions are installed:
cakephp/cakephp 4.4.10
cakephp/migrations 3.7.1
robmorgan/phinx 0.13.3
I am using Docker Containers running 10.10.2-MariaDB and 8.1-PHP.
I also tried Vagrant VMs and there is the same behaviour. In an older VM everything works. In a fresh VM I have the same problem.