From a19eec779168818db11b045b863f8d32e32dab8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 00:41:44 +0100 Subject: [PATCH] FIX #16135 --- .../install/mysql/migration/12.0.0-13.0.0.sql | 15 +++++++++++--- .../mysql/tables/llx_c_product_nature.key.sql | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 31cdf9c8d62..96a681d4c56 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -415,8 +415,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255); DELETE FROM llx_const WHERE name in ('MAIN_INCLUDE_ZERO_VAT_IN_REPORTS'); -UPDATE llx_projet_task_time SET tms = null WHERE tms = 0; -ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; + +-- VMYSQL4.1 UPDATE llx_projet_task_time SET tms = null WHERE tms = 0; + +ALTER TABLE llx_projet_task_time CHANGE COLUMN tms tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime; @@ -432,12 +434,19 @@ CREATE TABLE llx_c_product_nature ( active tinyint DEFAULT 1 NOT NULL ) ENGINE=innodb; -ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code, active); + +ALTER TABLE llx_product DROP FOREIGN KEY fk_product_finished; + +-- VMYSQL4.1 DROP INDEX uk_c_product_nature on llx_c_product_nature; +-- VPGSQL8.2 DROP INDEX uk_c_product_nature; + +ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code); INSERT INTO llx_c_product_nature (code, label, active) VALUES (0, 'RowMaterial', 1); INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1); ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; + ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); -- MIGRATION TO DO AFTER RENAMING AN OBJECT diff --git a/htdocs/install/mysql/tables/llx_c_product_nature.key.sql b/htdocs/install/mysql/tables/llx_c_product_nature.key.sql index b6a3d2130bf..e1190e5ab19 100644 --- a/htdocs/install/mysql/tables/llx_c_product_nature.key.sql +++ b/htdocs/install/mysql/tables/llx_c_product_nature.key.sql @@ -1 +1,19 @@ -ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code, active); +-- ======================================================================== +-- Copyright (C) 2021 Laurent Destailleur +-- +-- 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_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code);