From 1e15f50ac795c25ebf70ffe496206711c469f86c Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 19 Jan 2023 17:05:56 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20problemi=20integrit=C3=A0=20db=20se=20si?= =?UTF-8?q?=20aggiorna=20(o=20si=20=C3=A8=20aggiornato=20in=20passato)=20d?= =?UTF-8?q?a=20una=20versione=20precedente=20alla=202.4.28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update/2_4_28.sql | 13 +++++++++++-- update/2_4_40.sql | 10 +++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/update/2_4_28.sql b/update/2_4_28.sql index 987150b02..36dc8cdea 100644 --- a/update/2_4_28.sql +++ b/update/2_4_28.sql @@ -33,7 +33,11 @@ UPDATE `zz_prints` SET `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` INSERT INTO `zz_prints` (`id`, `id_module`, `is_record`, `name`, `title`, `filename`, `directory`, `previous`, `options`, `icon`, `version`, `compatibility`, `order`, `predefined`, `default`, `enabled`) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name`='Stampe contabili'), '1', 'Libro giornale', 'Libro giornale', 'Libro giornale', 'libro_giornale', 'idconto', '', 'fa fa-print', '', '', '0', '0', '1', '1'); -- Aggiunta tabella mansioni -CREATE TABLE IF NOT EXISTS `an_mansioni` ( `id` INT NOT NULL AUTO_INCREMENT , `nome` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)); +CREATE TABLE IF NOT EXISTS `an_mansioni` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nome` VARCHAR(100) NOT NULL, + PRIMARY KEY (`id`) +); INSERT INTO `an_mansioni`( `nome` @@ -56,7 +60,12 @@ INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `visible`, UPDATE `zz_plugins` SET `options` = ' { \"main_query\": [ { \"type\": \"table\", \"fields\": \"Nominativo, Mansione, Telefono, Indirizzo email, Sede\", \"query\": \"SELECT an_referenti.id, an_referenti.nome AS Nominativo, an_mansioni.nome AS Mansione, an_referenti.telefono AS Telefono, an_referenti.email AS \'Indirizzo email\', IF(idsede = 0, \'Sede legale\', an_sedi.nomesede) AS Sede FROM an_referenti LEFT OUTER JOIN an_sedi ON idsede = an_sedi.id LEFT OUTER JOIN an_mansioni ON idmansione = an_mansioni.id WHERE 1=1 AND an_referenti.idanagrafica=|id_parent| HAVING 2=2 ORDER BY an_referenti.id DESC\"} ]}' WHERE `zz_plugins`.`name` = 'Referenti'; -CREATE TABLE IF NOT EXISTS `em_mansioni_template` ( `id` INT NOT NULL AUTO_INCREMENT , `idmansione` INT NOT NULL , `id_template` INT NOT NULL , PRIMARY KEY (`id`)); +CREATE TABLE IF NOT EXISTS `em_mansioni_template` ( + `id` INT NOT NULL AUTO_INCREMENT, + `idmansione` INT NOT NULL, + `id_template` INT NOT NULL, + PRIMARY KEY (`id`) +); -- Aggiunta notifiche ai tecnici assegnati ALTER TABLE `in_statiintervento` CHANGE `notifica_tecnici` `notifica_tecnico_sessione` TINYINT(4) NOT NULL; diff --git a/update/2_4_40.sql b/update/2_4_40.sql index 7226cca47..86fe7bd62 100644 --- a/update/2_4_40.sql +++ b/update/2_4_40.sql @@ -97,4 +97,12 @@ HAVING ORDER BY `data` DESC, CAST(`numero_esterno` AS UNSIGNED) DESC, - `dt_ddt`.created_at DESC" WHERE `name` = 'Ddt di vendita'; \ No newline at end of file + `dt_ddt`.created_at DESC" WHERE `name` = 'Ddt di vendita'; + + +-- Fix problemi integrità db se si aggiorna (o si è aggiornato in passato) da una versione precedente alla 2.4.28 +ALTER TABLE `an_mansioni` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `an_mansioni` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; + +ALTER TABLE `em_mansioni_template` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `em_mansioni_template` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; \ No newline at end of file