Fix: Clean before adding foreign key

This commit is contained in:
Laurent Destailleur
2014-07-20 04:42:05 +02:00
parent d87e146e47
commit d80de2cdd4

View File

@@ -96,10 +96,11 @@ ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_b
-- Added missing relations of llx_product_price -- Added missing relations of llx_product_price
-- fk_user_author -- fk_user_author
ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_user_author (fk_user_author); ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_user_author (fk_user_author);
update llx_product_price set fk_user_author = null where fk_user_author = 0; UPDATE llx_product_price set fk_user_author = null where fk_user_author = 0;
ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
-- fk_user_author -- fk_user_author
ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_product (fk_product); ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_product (fk_product);
DELETE from llx_product_price where fk_product NOT IN (SELECT rowid from llx_product);
ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_account integer AFTER date_livraison; ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_account integer AFTER date_livraison;