diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 47108629244..c53c892bada 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -540,8 +540,11 @@ ALTER TABLE llx_product ADD COLUMN volume_units tinyint DEFAULT NULL after volum ALTER TABLE llx_product modify ref varchar(32) NOT NULL; -ALTER TABLE `llx_socpeople` CHANGE `fk_user` `fk_user_creat` INT( 11 ) NULL DEFAULT '0'; -ALTER TABLE `llx_socpeople` CHANGE `fk_user_create` `fk_user_creat` INT( 11 ) NULL DEFAULT '0'; +ALTER TABLE `llx_socpeople` CHANGE `fk_user` `fk_user_creat` INT(11) NULL; +ALTER TABLE `llx_socpeople` CHANGE `fk_user_create` `fk_user_creat` INT(11) NULL; +-- V4 UPDATE llx_socpeople set fk_user_creat = null where llx_socpeople.fk_user_creat is not null and llx_socpeople.fk_user_creat not in (select rowid from llx_user); +-- V4 ALTER TABLE llx_socpeople ADD INDEX idx_fk_user_creat (fk_user_creat); +-- V4 ALTER TABLE llx_socpeople ADD CONSTRAINT fk_socpeople_user_creat_user_rowid FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); drop table if exists llx_soc_events; diff --git a/mysql/tables/llx_socpeople.key.sql b/mysql/tables/llx_socpeople.key.sql index eb5f4707761..baacfede43f 100644 --- a/mysql/tables/llx_socpeople.key.sql +++ b/mysql/tables/llx_socpeople.key.sql @@ -1,5 +1,5 @@ -- ============================================================================ --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005-2007 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -22,4 +22,7 @@ ALTER TABLE llx_socpeople ADD INDEX idx_socpeople_fk_soc (fk_soc); +ALTER TABLE llx_socpeople ADD INDEX idx_fk_user_creat (fk_user_creat); + ALTER TABLE llx_socpeople ADD CONSTRAINT fk_socpeople_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); +ALTER TABLE llx_socpeople ADD CONSTRAINT fk_socpeople_user_creat_user_rowid FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid);