Skip to content

Commit

Permalink
Create correct FKCs
Browse files Browse the repository at this point in the history
  • Loading branch information
blackcoder87 committed Nov 27, 2024
1 parent 34dc2cf commit 40ee4c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions application/modules/user/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,10 @@ public function getUpdate(string $installedVersion): string
$this->db()->query('ALTER TABLE `[prefix]_users_groups` ADD CONSTRAINT `FK_[prefix]_users_groups_[prefix]_users` FOREIGN KEY (`user_id`) REFERENCES `[prefix]_users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
}
if (!$this->db()->queryCell("SELECT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE table_schema='" . $dbname . "' AND table_name='[prefix]_users_groups' AND constraint_name='FK_[prefix]_users_groups_[prefix]_groups');")) {
$this->db()->query('ALTER TABLE `[prefix]_users_groups` ADD CONSTRAINT `FK_[prefix]_users_groups_[prefix]_users` FOREIGN KEY (`user_id`) REFERENCES `[prefix]_users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
$this->db()->query('ALTER TABLE `[prefix]_users_groups` ADD CONSTRAINT `FK_[prefix]_users_groups_[prefix]_groups` FOREIGN KEY (`group_id`) REFERENCES `[prefix]_groups` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
}
if (!$this->db()->queryCell("SELECT EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE table_schema='" . $dbname . "' AND table_name='[prefix]_users_groups' AND constraint_name='FK_[prefix]_groups_access_[prefix]_groups');")) {
$this->db()->query('ALTER TABLE `[prefix]_users_groups` ADD CONSTRAINT `FK_[prefix]_users_groups_[prefix]_users` FOREIGN KEY (`user_id`) REFERENCES `[prefix]_users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
$this->db()->query('ALTER TABLE `[prefix]_users_groups` ADD CONSTRAINT `FK_[prefix]_groups_access_[prefix]_groups` FOREIGN KEY (`group_id`) REFERENCES `[prefix]_groups` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE;');
}

// auth_tokens
Expand Down

0 comments on commit 40ee4c2

Please sign in to comment.