From e33b47a3c6efa5e6d89b6398b11ee50fee4a1db3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Aug 2006 20:01:44 +0000 Subject: [PATCH] Correction pb sur migration --- mysql/migration/2.0.0-2.1.0.sql | 39 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index c9043e70b15..d8436cf55db 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -322,27 +322,30 @@ alter table llx_facture add column fk_facture integer after fk_user_valid; ALTER TABLE llx_facture ADD INDEX idx_facture_fk_facture (fk_facture); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facture (rowid); -ALTER TABLE llx_societe_remise_except DROP FOREIGN KEY fk_societe_remise_fk_facture; -ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facturedet (rowid); -- drop table llx_societe_remise_except; --- create table llx_societe_remise_except --- ( --- rowid integer AUTO_INCREMENT PRIMARY KEY, --- fk_soc integer NOT NULL, --- datec datetime, --- amount_ht real NOT NULL, --- fk_user integer NOT NULL, --- fk_facture integer, --- description varchar(255) NOT NULL --- )type=innodb; --- ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_user (fk_user); --- ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_soc (fk_soc); --- ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_facture (fk_facture); --- ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); --- ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); --- ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facturedet (rowid); +create table llx_societe_remise_except +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_soc integer NOT NULL, + datec datetime, + amount_ht real NOT NULL, + fk_user integer NOT NULL, + fk_facture integer, + description varchar(255) NOT NULL +)type=innodb; +-- Supprimme orphelins pour permettre montée de la clé +-- V4 DELETE llx_societe_remise_except FROM llx_societe_remise_except LEFT JOIN llx_facturedet ON llx_societe_remise_except.fk_facture = llx_facturedet.rowid WHERE llx_facturedet.rowid IS NULL; + +ALTER TABLE llx_societe_remise_except DROP FOREIGN KEY fk_societe_remise_fk_facture; + +ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_user (fk_user); +ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_soc (fk_soc); +ALTER TABLE llx_societe_remise_except ADD INDEX idx_societe_remise_except_fk_facture (fk_facture); +ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); +ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); +ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facturedet (rowid); update llx_societe_remise_except set description='Remise sans description' where description is NULL or description =''; alter table llx_societe_remise_except modify description varchar(255) NOT NULL;