diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 4ab08dc7415..0f82ef022f2 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -316,6 +316,10 @@ alter table llx_propaldet add column rang integer DEFAULT 0; alter table llx_facture drop column model; alter table llx_facture add column model_pdf varchar(50) after note_public; +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); + update llx_societe_remise_except set description='Remise sans description' where description is NULL or description =''; diff --git a/mysql/tables/llx_facture.key.sql b/mysql/tables/llx_facture.key.sql index 93b8d12ec7f..b99e7996cf4 100644 --- a/mysql/tables/llx_facture.key.sql +++ b/mysql/tables/llx_facture.key.sql @@ -25,11 +25,13 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_soc (fk_soc); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_author (fk_user_author); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_user_valid (fk_user_valid); +ALTER TABLE llx_facture ADD INDEX idx_facture_fk_facture (fk_facture); ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (idp); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); -ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_facture FOREIGN KEY (fk_facture) REFERENCES llx_facture (rowid); ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber); diff --git a/mysql/tables/llx_facture.sql b/mysql/tables/llx_facture.sql index 30a3a58262a..ffa07ac489f 100644 --- a/mysql/tables/llx_facture.sql +++ b/mysql/tables/llx_facture.sql @@ -44,6 +44,7 @@ create table llx_facture fk_user_author integer, -- createur de la facture fk_user_valid integer, -- valideur de la facture + fk_facture integer, -- facture origine si facture avoir fk_projet integer, -- projet auquel est associée la facture fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)