Dolibarr ERP & CRM » Bugs » bug #1754 Error while installing 3.7Latest modifications
Answer now
Snapshot Details |
Last Modified On: | 2014-12-29 15:11 | | Submitted by: | Marcos García (marcosgdf) |
Submitted on: | 2014-12-23 11:21 | |
Summary: | Error while installing 3.7 |
Description: | Request 234 : ALTER TABLE llx_c_departements ADD CONSTRAINT fk_departements_fk_region FOREIGN KEY (fk_region) REFERENCES llx_c_regions (code_region) Error de SQL DB_ERROR_1215 Cannot add foreign key constraint |
Step to reproduce bug: | |
Detected in version: | 3.7.0 | | Category: | Core Problem |
Severity: | 7 | | OS Type/Version: | |
PHP version: | | | Database type and version: | |
Status |
Status: | Open | | Assigned to: | Marcos García (marcosgdf) |
Resolution: | Fixed | |
Comments- Laurent Destailleur 2015-01-05 09:18
- To have the install and upgrade process working correctly, we should never have constraint coded into the creation of table. All constraints must have an explicit name.
That why the creation of index must be done into the .key.sql file.
And creation of unique index is done by the
ALTER TABLE llx_c_regions ADD UNIQUE INDEX uk_code_region (code_region);
Why removing it in the patch ? - Marcos García 2014-12-29 15:11
- The bug has been corrected. Pull request send inside GIT sources
(http://www.github.com/Dolibarr/dolibarr) and waiting to merge
into develop branch. - Marcos García 2014-12-26 00:36
- In PostgreSQL:
Request 235 : ALTER TABLE llx_c_departements ADD CONSTRAINT fk_departements_fk_region FOREIGN KEY (fk_region) REFERENCES llx_c_regions (code_region) DEFERRABLE INITIALLY IMMEDIATE; Error de SQL DB_ERROR_42830 ERROR: 42830: there is no unique constraint matching given keys for referenced table "llx_c_regions" LOCATION: transformFkeyCheckAttrs, tablecmds.c:6609 - Marcos García 2014-12-23 14:57
- It was a new install.
sql> ALTER TABLE llx_c_regions ADD UNIQUE INDEX uk_code_region (code_region)
[2014-12-23 14:57:17] completed in 7 ms
[2014-12-23 14:57:17] [42000][1061] Duplicate key name 'uk_code_region' - Laurent Destailleur 2014-12-23 12:06
- Do you have a record with code_region = 0 into table llx_c_regions ?
If you run manually request
ALTER TABLE llx_c_regions ADD UNIQUE INDEX uk_code_region (code_region);
do you have a message like "index already exists" ?
|
|
That why the creation of index must be done into the .key.sql file.
And creation of unique index is done by the
ALTER TABLE llx_c_regions ADD UNIQUE INDEX uk_code_region (code_region);
Why removing it in the patch ?