From 1d929d267c89c657bf2a527b0b5d0f9cf9d174cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Ferry?= <jfefe@aternatik.fr>
Date: Sat, 15 Mar 2014 22:23:43 +0100
Subject: [PATCH] Move table creation instruction into migration tables

---
 .../install/mysql/migration/3.5.0-3.6.0.sql   | 44 ++++++++++++++++---
 .../tables/llx_element_resources.key.sql      |  3 --
 .../install/mysql/tables/llx_resource.key.sql |  3 +-
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
index 35b8571813a..400d26af2b2 100644
--- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
+++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
@@ -1003,7 +1003,7 @@ create table llx_product_customer_price
   datec					datetime,
   tms					timestamp,
   fk_product			integer NOT NULL,
-  fk_soc				integer NOT NULL,	   
+  fk_soc				integer NOT NULL,
   price						double(24,8) DEFAULT 0,
   price_ttc					double(24,8) DEFAULT 0,
   price_min					double(24,8) DEFAULT 0,
@@ -1011,7 +1011,7 @@ create table llx_product_customer_price
   price_base_type			varchar(3)   DEFAULT 'HT',
   tva_tx					double(6,3),
   recuperableonly           integer NOT NULL DEFAULT '0',   -- Other NPR VAT
-  localtax1_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 1 
+  localtax1_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 1
   localtax2_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 2
   fk_user				    integer,
   import_key			    varchar(14)                  -- Import key
@@ -1038,7 +1038,7 @@ create table llx_product_customer_price_log
   entity				integer DEFAULT 1 NOT NULL,	   -- multi company id
   datec                       datetime,
   fk_product			integer NOT NULL,
-  fk_soc				integer NOT NULL,	   
+  fk_soc				integer NOT NULL,
   price						double(24,8) DEFAULT 0,
   price_ttc					double(24,8) DEFAULT 0,
   price_min					double(24,8) DEFAULT 0,
@@ -1046,7 +1046,7 @@ create table llx_product_customer_price_log
   price_base_type			varchar(3)   DEFAULT 'HT',
   tva_tx					double(6,3),
   recuperableonly           integer NOT NULL DEFAULT 0,   -- Other NPR VAT
-  localtax1_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 1 
+  localtax1_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 1
   localtax2_tx				double(6,3)  DEFAULT 0,         -- Other local VAT 2
   fk_user				integer,
  import_key			varchar(14)                  -- Import key
@@ -1091,10 +1091,10 @@ CREATE TABLE llx_payment_salary (
   num_payment varchar(50),
   label varchar(255),
   datesp date,                       -- date de début de la période
-  dateep date,                       -- date de fin de la période    
+  dateep date,                       -- date de fin de la période
   entity integer DEFAULT 1 NOT NULL,	-- multi company id
   note text,
-  fk_bank integer,  
+  fk_bank integer,
   fk_user_creat integer,
   fk_user_modif integer
 )ENGINE=innodb;
@@ -1155,3 +1155,35 @@ create table llx_categorie_lang
 
 ALTER TABLE llx_categorie_lang ADD UNIQUE INDEX uk_category_lang (fk_category, lang);
 ALTER TABLE llx_categorie_lang ADD CONSTRAINT fk_category_lang_fk_category 	FOREIGN KEY (fk_category) REFERENCES llx_categorie (rowid);
+
+-- Resource module
+CREATE TABLE llx_resource
+(
+  rowid           		integer AUTO_INCREMENT PRIMARY KEY,
+  entity          		integer,
+  ref             		varchar(255),
+  description     		text,
+  fk_code_type_resource varchar(32),
+  note_public     		text,
+  note_private    		text,
+  tms         			timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
+
+CREATE TABLE llx_element_resources
+(
+  rowid           integer AUTO_INCREMENT PRIMARY KEY,
+  resource_id     integer,
+  resource_type	  varchar(64),
+  element_id	  integer,
+  element_type    varchar(64),
+  busy			  integer,
+  mandatory		  integer,
+  fk_user_create   integer,
+  tms             timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
+ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
+-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
diff --git a/htdocs/install/mysql/tables/llx_element_resources.key.sql b/htdocs/install/mysql/tables/llx_element_resources.key.sql
index e75b2dfc0e3..72dd5f3d850 100644
--- a/htdocs/install/mysql/tables/llx_element_resources.key.sql
+++ b/htdocs/install/mysql/tables/llx_element_resources.key.sql
@@ -18,9 +18,6 @@
 
 
 ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
-
-	
 ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
-
 -- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
 	
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_resource.key.sql b/htdocs/install/mysql/tables/llx_resource.key.sql
index 71cbedc1c66..62eb21056c4 100755
--- a/htdocs/install/mysql/tables/llx_resource.key.sql
+++ b/htdocs/install/mysql/tables/llx_resource.key.sql
@@ -15,5 +15,4 @@
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-ALTER TABLE llx_place ADD CONSTRAINT fk_place_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople (rowid);
-ALTER TABLE llx_place ADD INDEX fk_socpeople_place (fk_socpeople);
\ No newline at end of file
+ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
\ No newline at end of file
-- 
GitLab