2017-08-04 16:28:16 +02:00
< ? php
/*
* Inserimento valori di default
*/
// Permessi di default delle viste
$gruppi = $database -> fetchArray ( 'SELECT `id` FROM `zz_groups`' );
$results = $database -> fetchArray ( 'SELECT `id` FROM `zz_views` WHERE `id` NOT IN (SELECT `id_vista` FROM `zz_group_view`)' );
$array = [];
foreach ( $results as $result ) {
foreach ( $gruppi as $gruppo ) {
$array [] = [
'id_gruppo' => $gruppo [ 'id' ],
'id_vista' => $result [ 'id' ],
];
}
}
if ( ! empty ( $array )) {
$database -> insert ( 'zz_group_view' , $array );
}
/*
* Fix
*/
// Fix per i contenuti ini inseriti all'interno del database
$database -> query ( " UPDATE mg_articoli SET contenuto = REPLACE(REPLACE(REPLACE(contenuto, '"', ' \" '), ' \n ', " . prepare ( PHP_EOL ) . " ), '`', ' \" ') " );
$database -> query ( " UPDATE my_impianto_componenti SET contenuto = REPLACE(REPLACE(REPLACE(contenuto, '"', ' \" '), ' \n ', " . prepare ( PHP_EOL ) . " ), '`', ' \" ') " );
2017-08-30 14:43:38 +02:00
// Fix per la presenza della Foreign Key in in_interventi_tecnici
$fk = $database -> fetchArray ( 'SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = ' . prepare ( $database -> getDatabaseName ()) . " AND REFERENCED_TABLE_NAME = 'in_interventi' AND CONSTRAINT_NAME = 'in_interventi_tecnici_ibfk_1' " );
2017-08-31 10:09:06 +02:00
if ( ! empty ( $fk )) {
$database -> query ( 'ALTER TABLE `in_interventi_tecnici` DROP FOREIGN KEY `in_interventi_tecnici_ibfk_1`' );
2017-08-30 14:43:38 +02:00
}
2017-08-31 10:09:06 +02:00
$database -> query ( 'ALTER TABLE `in_interventi` DROP PRIMARY KEY, CHANGE `idintervento` `codice` varchar(25) NOT NULL UNIQUE, ADD PRIMARY KEY (`id`)' );
$database -> query ( 'DROP INDEX primary_key ON `in_interventi`' );
$database -> query ( 'UPDATE `in_interventi_tecnici` SET `idintervento` = (SELECT `id` FROM `in_interventi` WHERE `in_interventi`.`codice` = `in_interventi_tecnici`.`idintervento`)' );
$database -> query ( 'ALTER TABLE `in_interventi_tecnici` CHANGE `idintervento` `idintervento` varchar(25)' );
2017-08-30 15:29:52 +02:00
$database -> query ( " UPDATE `in_interventi_tecnici` SET `idintervento` = NULL WHERE `idintervento` = 0 OR `idintervento` = '' " );
2017-08-31 10:09:06 +02:00
$database -> query ( 'ALTER TABLE `in_interventi_tecnici` CHANGE `idintervento` `idintervento` int(11), ADD FOREIGN KEY (`idintervento`) REFERENCES `in_interventi`(`id`) ON DELETE CASCADE' );
2017-08-30 14:43:38 +02:00
2017-08-28 15:01:02 +02:00
// Fix dei timestamp delle tabelle mg_prodotti, mg_movimenti, zz_logs e zz_files
2017-08-31 10:09:06 +02:00
$database -> query ( 'UPDATE `mg_prodotti` SET `created_at` = `data`' );
2017-08-28 15:01:02 +02:00
$database -> query ( 'ALTER TABLE `mg_prodotti` DROP `data`' );
2017-08-31 10:09:06 +02:00
$database -> query ( 'UPDATE `mg_movimenti` SET `created_at` = `data`' );
2017-08-28 15:01:02 +02:00
$database -> query ( 'ALTER TABLE `mg_movimenti` DROP `data`' );
2017-08-31 10:09:06 +02:00
$database -> query ( 'UPDATE `zz_logs` SET `created_at` = `timestamp`' );
2017-08-04 16:28:16 +02:00
$database -> query ( 'ALTER TABLE `zz_logs` DROP `timestamp`' );
2017-08-31 10:09:06 +02:00
$database -> query ( 'UPDATE `zz_files` SET `created_at` = `data`' );
2017-08-04 16:28:16 +02:00
$database -> query ( 'ALTER TABLE `zz_files` DROP `data`' );
/*
2018-02-14 12:39:26 +01:00
* Rimozione file e cartelle deprecati [ in 2.3 . 1 per risolvere un problema sui percorsi ]
2017-08-04 16:28:16 +02:00
*/