-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade 19.0.3->20.0.0 PostgresSQL migration error in llx_societe_commerciaux #30995
Comments
Can you paste also the content of select * from llx_c_type_contact |
Hi, Sure, sorry, I forgot to add the dump in my initial report. At least it shows that "code" is not unique... Cheers, |
This is the same for me using PHP 8.2 and Postgresql. Maybe the unique constraint was not created for postgresql during previous migrations. We could create it manually but I will wait for eldy's answer on that before I have to revert from the backup again. |
I tried to create a unique constraint but the code field is not unique (the combimation element, source and code is) which breaks the foreign key constraint in llx_societe_commerciaux because code is referenced which is not unique. I don't understand why the upgrade is possible in MariaDB. I attached my table too. |
I am using PostgreSQL and am trying to upgrade to dolibarr 20.0.0 from 19.0.3. I get the same error. And like GMellar the [code] field that the migration process is trying to use does not have unique entries in it making the foreign key impossible to make. |
The table In the v20 release, a new column, Currently, the |
I agree when it is not used the issue could be addressed later but Ignoring this error is not possible because that's the way a relational database works. A foreign key can not be created with the current data structure. When the column is not used a solution could be to remove it in an update. I still do not know why there is no complaint on mariadb. At least some people should have updated to 20.0.0. |
I'm baffled. It seems MySQL accepts non-unique fkeys. FWIW: I can confirm both create and upgrade does work on MariaDB 1:10.11.6-0+deb12u1 (see log) Both MySQL and PostgreSQL (correctly) deny to create an unique index on "code" in "llx_c_type_contact", but For now i think it's safe commenting out the creation of fk_societe_commerciaux_fk_c_type_contact_code as long as code is not used. At least that's what I did. |
I will try that but I'm not sure if this is the right way to solve this. It won't cause any trouble because the default value on fk_c_type_contact_code is set to 'SALESREPTHIRD' so even if there is no foreign key and the column is used in the code it won't break anything but the database consistency. |
Hi there! Any news?
Which is the most important |
Same problem here. |
Same issue here migrating from 19.0.3 to 20.0.0 or 20.0.1. NB ALTER TABLE llx_societe_commerciaux ADD COLUMN fk_c_type_contact_code varchar(32) NOT NULL DEFAULT 'SALESREPTHIRD'; ALTER TABLE llx_societe_commerciaux ADD UNIQUE INDEX uk_societe_commerciaux_c_type_contact (fk_soc, fk_user, fk_c_type_contact_code); |
Hi, |
Hi there! Any news? This is a blocking issue that prevents upgrade to Dolibarr 20.0.0 when using Postgres DB. ping @eldy Thank you! |
Bug
Hi,
I tried to upgrade 19.0.3 to 20.0.0. The database migration scripts throws an error:
DB_ERROR_42830 (Req 220): ALTER TABLE llx_societe_commerciaux ADD CONSTRAINT fk_societe_commerciaux_fk_c_type_contact_code FOREIGN KEY (fk_c_type_contact_code) REFERENCES llx_c_type_contact(code);
ERROR: 42830: there is no unique constraint matching given keys for referenced table "llx_c_type_contact" LOCATION: transformFkeyCheckAttrs, tablecmds.c:11602
I ignored the error for now, and it seems to work.
Cheers,
Michael
Dolibarr Version
20.0.0
Environment PHP
8.2.20-1~deb12u1
Environment Database
PostgreSQL 15.8-0+deb12u1
Steps to reproduce the behavior and expected behavior
Attached files
olibarr=# select * from llx_societe_commerciaux;
rowid | fk_soc | fk_user | import_key | fk_c_type_contact_code
-------+--------+---------+------------+------------------------
1 | 24 | 3 | | SALESREPTHIRD
2 | 25 | 3 | | SALESREPTHIRD
(2 rows)
The text was updated successfully, but these errors were encountered: