Private GIT

Skip to content
Snippets Groups Projects
Commit fdbd44a5 authored by Kevin Duret's avatar Kevin Duret Committed by Matthieu Kermagoret
Browse files

fix(upgrade): fix foregin key upgrade of traps_group table

parent 05015314
Branches
Tags
No related merge requests found
...@@ -37,17 +37,31 @@ if (isset($pearDB)) { ...@@ -37,17 +37,31 @@ if (isset($pearDB)) {
"SHOW INDEXES FROM `traps_group` WHERE key_name = 'PRIMARY'" "SHOW INDEXES FROM `traps_group` WHERE key_name = 'PRIMARY'"
); );
if ($res->numRows() <= 0) { if ($res->numRows() <= 0) {
$pearDB->query(
"ALTER TABLE `traps_group_relation` " .
"DROP FOREIGN KEY `traps_group_relation_ibfk_2`"
);
$pearDB->query( $pearDB->query(
"ALTER TABLE `traps_group` " . "ALTER TABLE `traps_group` " .
" CHANGE COLUMN `traps_group_id` " . " CHANGE COLUMN `traps_group_id` " .
" `traps_group_id` INT NOT NULL AUTO_INCREMENT" " `traps_group_id` INT NOT NULL AUTO_INCREMENT"
); );
$pearDB->query(
"ALTER TABLE `traps_group_relation` " .
"ADD CONSTRAINT `traps_group_relation_ibfk_2` " .
"FOREIGN KEY (`traps_group_id`) REFERENCES `traps_group` (`traps_group_id`) ON DELETE CASCADE"
);
$pearDB->query( $pearDB->query(
"ALTER TABLE `traps_group` ADD PRIMARY KEY (`traps_group_id`)" "ALTER TABLE `traps_group` ADD PRIMARY KEY (`traps_group_id`)"
); );
$pearDB->query( $pearDB->query(
"ALTER TABLE `traps_group` " . "ALTER TABLE `traps_group` " .
" DROP KEY `traps_group_id`" " DROP KEY `traps_group_id`"
); );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment