1+ <?php
2+ /**
3+ -------------------------------------------------------------------------
4+
5+ LICENSE
6+
7+ This file is part of Behaviors plugin for GLPI.
8+
9+ Behaviors is free software: you can redistribute it and/or modify
10+ it under the terms of the GNU Affero General Public License as published by
11+ the Free Software Foundation, either version 3 of the License, or
12+ (at your option) any later version.
13+
14+ Behaviors is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ GNU Affero General Public License for more details.
18+
19+ You should have received a copy of the GNU Affero General Public License
20+ along with Behaviors. If not, see <http://www.gnu.org/licenses/>.
21+
22+ @package behaviors
23+ @author Nelly Mahu-Lasson
24+ @copyright Copyright (c) 2022 Behaviors plugin team
25+ @license AGPL License 3.0 or (at your option) any later version
26+ http://www.gnu.org/licenses/agpl-3.0-standalone.html
27+ @link https://forge.glpi-project.org/projects/behaviors
28+ @link http://www.glpi-project.org/
29+ @since version 0.83.4
30+
31+ --------------------------------------------------------------------------
32+ */
33+ if (!defined ('GLPI_ROOT ' )) {
34+ include ('../../../inc/includes.php ' );
35+ }
36+
37+
38+ // for big database
39+ ini_set ("max_execution_time " , "0 " );
40+ ini_set ("memory_limit " , "-1 " );
41+
42+ global $ DB ;
43+
44+ $ sql = "SELECT `table_name`
45+ FROM information_schema.tables
46+ WHERE `table_schema` = ' " .$ DB ->dbdefault ."'
47+ AND `table_name` LIKE 'glpi_%' " ;
48+ $ tables = $ DB ->request ($ sql );
49+
50+ foreach ($ tables as $ table ) {
51+ if ($ DB ->FieldExists ($ table ['table_name ' ], 'tickets_id ' )) {
52+ $ query = "ALTER TABLE " .$ table ['table_name ' ] ." CHANGE `tickets_id` `tickets_id` INT(11) UNSIGNED NOT NULL; " ;
53+ $ DB ->queryOrDie ($ query );
54+ }
55+ if ($ DB ->FieldExists ($ table ['table_name ' ], 'items_id ' )) {
56+ $ query = "ALTER TABLE " .$ table ['table_name ' ] ." CHANGE `items_id` `items_id` INT(11) UNSIGNED NOT NULL; " ;
57+ $ DB ->queryOrDie ($ query );
58+ }
59+ }
60+
61+ $ query = "ALTER TABLE `glpi_tickets` CHANGE `id` `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT; " ;
62+ $ DB ->queryOrDie ($ query );
0 commit comments