Skip to content

Commit

Permalink
Add cascade operations and insert trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Aug 20, 2024
1 parent 5046551 commit e44b171
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
23 changes: 20 additions & 3 deletions SQL/paradise_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,24 @@ ALTER TABLE `player` ADD `species_whitelist` LONGTEXT COLLATE utf8mb4_unicode_ci

DROP TABLE IF EXISTS `player_220`;
CREATE TABLE `player_220` (
`ckey` VARCHAR(64) NOT NULL COLLATE 'utf8mb4_general_ci',
`toggles_220` int(11) DEFAULT NULL,
`ckey` VARCHAR(32) NOT NULL COLLATE utf8mb4_unicode_ci,
`toggles` int(11) DEFAULT NULL,
PRIMARY KEY (`ckey`) USING BTREE
) COLLATE = 'utf8mb4_general_ci' ENGINE = InnoDB;
) COLLATE = utf8mb4_unicode_ci ENGINE = InnoDB;

ALTER TABLE `player_220`
ADD CONSTRAINT `fk_player_220_ckey`
FOREIGN KEY (`ckey`) REFERENCES `player`(`ckey`)
ON DELETE CASCADE
ON UPDATE CASCADE;

DELIMITER //
CREATE TRIGGER `player_insert`
AFTER INSERT ON `player`
FOR EACH ROW
BEGIN
INSERT INTO `player_220` (`ckey`)
VALUES (NEW.ckey);
END;
//
DELIMITER ;
23 changes: 20 additions & 3 deletions SQL/updates220/59.220.6-59.220.7.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@

DROP TABLE IF EXISTS `player_220`;
CREATE TABLE `player_220` (
`ckey` VARCHAR(64) NOT NULL COLLATE 'utf8mb4_general_ci',
`toggles_220` int(11) DEFAULT NULL,
`ckey` VARCHAR(32) NOT NULL COLLATE utf8mb4_unicode_ci,
`toggles` int(11) DEFAULT NULL,
PRIMARY KEY (`ckey`) USING BTREE
) COLLATE = 'utf8mb4_general_ci' ENGINE = InnoDB;
) COLLATE = utf8mb4_unicode_ci ENGINE = InnoDB;

ALTER TABLE `player_220`
ADD CONSTRAINT `fk_player_220_ckey`
FOREIGN KEY (`ckey`) REFERENCES `player`(`ckey`)
ON DELETE CASCADE
ON UPDATE CASCADE;

DELIMITER //
CREATE TRIGGER `player_insert`
AFTER INSERT ON `player`
FOR EACH ROW
BEGIN
INSERT INTO `player_220` (`ckey`)
VALUES (NEW.ckey);
END;
//
DELIMITER ;

0 comments on commit e44b171

Please sign in to comment.