Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix foreign key upgrade of traps_group table #5752

Merged
merged 2 commits into from
Oct 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions www/install/php/Update-2.8.14_to_2.8.15.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,30 @@
"SHOW INDEXES FROM `traps_group` WHERE key_name = 'PRIMARY'"
);
if ($res->numRows() <= 0) {
$pearDB->query(
"ALTER TABLE `traps_group_relation` " .
"DROP FOREIGN KEY `traps_group_relation_ibfk_2`"
);

$pearDB->query(
"ALTER TABLE `traps_group` " .
" CHANGE COLUMN `traps_group_id` " .
" `traps_group_id` INT NOT NULL AUTO_INCREMENT"
);

$pearDB->query(
"ALTER TABLE `traps_group` ADD PRIMARY KEY (`traps_group_id`)"
);

$pearDB->query(
"ALTER TABLE `traps_group` " .
" DROP KEY `traps_group_id`"
);

$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"
);
}
}