From 80de63d5a370794c64c856ffcc1c3ebc4def42a6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 21 Apr 2012 19:12:20 +0200
Subject: [PATCH] Fix: [ bug #372 ] Upgrade error from 3.1.0 to 3.2.0 Beta

---
 htdocs/install/mysql/migration/3.1.0-3.2.0.sql | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
index b3ef221cf1a..5aadfb066f9 100755
--- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
+++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql
@@ -213,9 +213,11 @@ ALTER TABLE llx_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowi
 ALTER TABLE llx_product_price ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
 
 -- Restore foreign key (on llx_expedition_methode before) on correct table (llx_c_shipment_mode)
+UPDATE llx_expedition SET fk_expedition_methode = null WHERE fk_expedition_methode NOT IN (SELECT rowid FROM llx_c_shipment_mode);
 ALTER TABLE llx_expedition DROP FOREIGN KEY fk_expedition_fk_expedition_methode;
 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode 	FOREIGN KEY (fk_expedition_methode) REFERENCES llx_c_shipment_mode (rowid);
 
+
 -- VMYSQL4.1 UPDATE llx_chargesociales set tms = date_creation WHERE tms = '0000-00-00 00:00:00';
 
 ALTER TABLE llx_propal MODIFY fk_projet integer DEFAULT NULL;
@@ -452,4 +454,4 @@ ALTER TABLE llx_facture_fourn ADD COLUMN extraparams varchar(255) AFTER import_k
 
 ALTER TABLE llx_boxes ADD COLUMN maxline integer NULL;
 
-ALTER TABLE llx_commande_fournisseur ADD COLUMN date_livraison date NULL;
\ No newline at end of file
+ALTER TABLE llx_commande_fournisseur ADD COLUMN date_livraison date NULL;
-- 
GitLab