diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 062525b3651..c57791c46ed 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -52,9 +52,38 @@ ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT N ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_date; + -- Localtaxes by thirds ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10); ALTER TABLE llx_c_tva MODIFY COLUMN localtax2 varchar(10); ALTER TABLE llx_localtax ADD COLUMN localtaxtype tinyint(4) after entity; ALTER TABLE llx_societe ADD COLUMN localtax1_value double(6,3) after localtax1_assuj; ALTER TABLE llx_societe ADD COLUMN localtax2_value double(6,3) after localtax2_assuj; + + + +-- Added missing relations of llx_product +-- fk_country +ALTER TABLE llx_product CHANGE fk_country fk_country INTEGER NULL DEFAULT NULL; +UPDATE llx_product SET fk_country = NULL WHERE fk_country = 0; +ALTER TABLE llx_product ADD INDEX idx_product_fk_country (fk_country); +ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_pays (rowid); +-- fk_user_author +ALTER TABLE llx_product CHANGE fk_user_author fk_user_author INTEGER NULL DEFAULT NULL; +ALTER TABLE llx_product ADD INDEX idx_product_fk_user_author (fk_user_author); +-- fk_barcode_type +ALTER TABLE llx_product CHANGE fk_barcode_type fk_barcode_type INTEGER NULL DEFAULT NULL; +UPDATE llx_product SET fk_barcode_type = NULL WHERE fk_barcode_type = 0; +ALTER TABLE llx_product ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); +ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); + + +-- Added missing relations of llx_product_price +-- 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; +ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +-- fk_user_author +ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_product (fk_product); +ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); + diff --git a/htdocs/install/mysql/tables/llx_product.key.sql b/htdocs/install/mysql/tables/llx_product.key.sql index a2cb0e539f9..218bd40490e 100644 --- a/htdocs/install/mysql/tables/llx_product.key.sql +++ b/htdocs/install/mysql/tables/llx_product.key.sql @@ -2,6 +2,7 @@ -- Copyright (C) 2002-2004 Rodolphe Quiedeville -- Copyright (C) 2004-2013 Laurent Destailleur -- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2014 Marcos García -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -25,6 +26,11 @@ ALTER TABLE llx_product ADD INDEX idx_product_label (label); ALTER TABLE llx_product ADD INDEX idx_product_barcode (barcode); ALTER TABLE llx_product ADD INDEX idx_product_import_key (import_key); ALTER TABLE llx_product ADD INDEX idx_product_seuil_stock_alerte (seuil_stock_alerte); - +ALTER TABLE llx_product ADD INDEX idx_product_fk_country (fk_country); +ALTER TABLE llx_product ADD INDEX idx_product_fk_user_author (fk_user_author); +ALTER TABLE llx_product ADD INDEX idx_product_fk_barcode_type (fk_barcode_type); ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity); + +ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_pays (rowid); +ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 0ff94c19530..0ab9a24785c 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -4,6 +4,7 @@ -- Copyright (C) 2005-2010 Regis Houssin -- Copyright (C) 2010 juanjo Menent -- Copyright (C) 2013 Cédric Salvador +-- Copyright (C) 2014 Marcos García -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ create table llx_product description text, note text, customcode varchar(32), -- Optionnal custom code - fk_country integer, -- Optionnal id of original country + fk_country integer DEFAULT NULL, -- Optionnal id of original country price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, @@ -47,7 +48,7 @@ create table llx_product recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1 localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2 - fk_user_author integer, + fk_user_author integer DEFAULT NULL, tosell tinyint DEFAULT 1, -- Product you sell tobuy tinyint DEFAULT 1, -- Product you buy tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch or eat-by management @@ -56,7 +57,7 @@ create table llx_product seuil_stock_alerte integer DEFAULT 0, url varchar(255), barcode varchar(255) DEFAULT NULL, - fk_barcode_type integer DEFAULT 0, + fk_barcode_type integer DEFAULT NULL, accountancy_code_sell varchar(32), -- Selling accountancy code accountancy_code_buy varchar(32), -- Buying accountancy code partnumber varchar(32), -- Not used. Used by external modules. diff --git a/htdocs/install/mysql/tables/llx_product_price.key.sql b/htdocs/install/mysql/tables/llx_product_price.key.sql new file mode 100644 index 00000000000..b3018cea95b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_price.key.sql @@ -0,0 +1,23 @@ +-- ============================================================================ +-- Copyright (C) 2014 Marcos García +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +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_product (fk_product); + +ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); +ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);