From d8af0f1c081ce94f460a4ad2cfd6a4f339efe465 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 29 Jun 2023 16:22:10 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20problemi=20integrit=C3=A0=20db=20per=20ca?= =?UTF-8?q?mpi=20created=5Fat=20e=20updated=5Fat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update/2_4_43.sql | 2 ++ update/2_4_47.sql | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/update/2_4_43.sql b/update/2_4_43.sql index 9825bb57e..31cab16cd 100644 --- a/update/2_4_43.sql +++ b/update/2_4_43.sql @@ -1,6 +1,8 @@ UPDATE `zz_widgets` SET `query` = 'SELECT COUNT(dati.id) AS dato FROM(SELECT id, ((SELECT SUM(co_righe_contratti.qta) FROM co_righe_contratti WHERE co_righe_contratti.um=\'ore\' AND co_righe_contratti.idcontratto=co_contratti.id) - IFNULL( (SELECT SUM(in_interventi_tecnici.ore) FROM in_interventi_tecnici INNER JOIN in_interventi ON in_interventi_tecnici.idintervento=in_interventi.id WHERE in_interventi.id_contratto=co_contratti.id AND in_interventi.idstatointervento IN (SELECT in_statiintervento.idstatointervento FROM in_statiintervento WHERE in_statiintervento.is_completato = 1)), 0) ) AS ore_rimanenti, DATEDIFF(data_conclusione, NOW()) AS giorni_rimanenti, data_conclusione, ore_preavviso_rinnovo, giorni_preavviso_rinnovo, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=co_contratti.idanagrafica) AS ragione_sociale FROM co_contratti WHERE rinnovabile = 1 AND YEAR(data_conclusione) > 1970 AND co_contratti.id NOT IN (SELECT idcontratto_prev FROM co_contratti contratti) HAVING (ore_rimanenti <= ore_preavviso_rinnovo OR DATEDIFF(data_conclusione, NOW()) <= ABS(giorni_preavviso_rinnovo)) ORDER BY giorni_rimanenti ASC, ore_rimanenti ASC) dati' WHERE `zz_widgets`.`name` = 'Contratti in scadenza'; +-- Fix problemi integrità db per campo valore ALTER TABLE `zz_settings` CHANGE `valore` `valore` TEXT NULL DEFAULT NULL; + -- Invio sollecito automatico INSERT INTO `zz_tasks` (`name`, `class`, `expression`) VALUES ('Solleciti scadenze', 'Modules\\Scadenzario\\SollecitoTask', '0 8 * * *'); diff --git a/update/2_4_47.sql b/update/2_4_47.sql index 5a0e8bdd5..490561e71 100644 --- a/update/2_4_47.sql +++ b/update/2_4_47.sql @@ -28,4 +28,14 @@ ALTER TABLE `dt_causalet` ADD `is_rientrabile` INT NOT NULL AFTER `is_importabil CREATE TABLE `zz_files_print` ( `id` INT NOT NULL AUTO_INCREMENT , `id_print` INT NOT NULL , `id_file` INT NOT NULL , PRIMARY KEY (`id`)); -- Modifica vista inviato Scadenzario -UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'IF(emails IS NOT NULL, \'SÌ\', \'NO\')' WHERE `zz_modules`.`name` = 'Scadenzario' AND `zz_views`.`name` = 'icon_title_Inviato'; \ No newline at end of file +UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'IF(emails IS NOT NULL, \'SÌ\', \'NO\')' WHERE `zz_modules`.`name` = 'Scadenzario' AND `zz_views`.`name` = 'icon_title_Inviato'; + +-- Fix problemi integrità db per campi created_at e updated_at +ALTER TABLE `in_righe_tipiinterventi` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `mg_listini` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `mg_listini_articoli` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `my_componenti` CHANGE `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `in_righe_tipiinterventi` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `mg_listini` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `mg_listini_articoli` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; +ALTER TABLE `my_componenti` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP; \ No newline at end of file