Skip to content

Commit

Permalink
Update db.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
yescallop committed Sep 19, 2024
1 parent 39f71ae commit aba62ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sql/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CREATE TABLE `changes` (
PRIMARY KEY (`code`, `new_code`, `time`) USING BTREE,
INDEX `desc_id`(`desc_id` ASC) USING BTREE,
CONSTRAINT `changes_ibfk_1` FOREIGN KEY (`desc_id`) REFERENCES `descriptions` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for codes
Expand All @@ -25,7 +25,7 @@ CREATE TABLE `codes` (
`start` int NOT NULL,
`end` int NULL DEFAULT NULL,
PRIMARY KEY (`code`, `start`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for descriptions
Expand All @@ -35,12 +35,12 @@ CREATE TABLE `descriptions` (
`id` int NOT NULL AUTO_INCREMENT,
`text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs;
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_zh_0900_as_cs ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- View structure for changes_ext
-- ----------------------------
DROP VIEW IF EXISTS `changes_ext`;
CREATE ALGORITHM = MERGE SQL SECURITY DEFINER VIEW `changes_ext` AS select `c`.`code` AS `code`,`p`.`name` AS `name`,`p`.`start` AS `start`,`c`.`new_code` AS `new_code`,`s`.`name` AS `new_name`,`s`.`start` AS `new_start`,`c`.`time` AS `time`,`c`.`desc_id` AS `desc_id` from ((`changes` `c` join `codes` `p` on(((`p`.`code` = `c`.`code`) and ((`c`.`time` - 1) >= `p`.`start`) and ((`p`.`end` is null) or ((`c`.`time` - 1) < `p`.`end`))))) join `codes` `s` on(((`s`.`code` = `c`.`new_code`) and (`c`.`time` >= `s`.`start`) and ((`s`.`end` is null) or (`c`.`time` < `s`.`end`)))));
CREATE ALGORITHM = MERGE SQL SECURITY DEFINER VIEW `changes_ext` AS select `c`.`code` AS `code`,`a`.`name` AS `name`,`a`.`start` AS `start`,`c`.`new_code` AS `new_code`,`b`.`name` AS `new_name`,`b`.`start` AS `new_start`,`c`.`time` AS `time`,`c`.`desc_id` AS `desc_id`,`d`.`text` AS `desc_text` from (((`changes` `c` join `codes` `a` on(((`a`.`code` = `c`.`code`) and (`a`.`start` < `c`.`time`) and ((`a`.`end` is null) or (`a`.`end` >= `c`.`time`))))) join `codes` `b` on(((`b`.`code` = `c`.`new_code`) and (`b`.`start` <= `c`.`time`) and ((`b`.`end` is null) or (`b`.`end` > `c`.`time`))))) left join `descriptions` `d` on((`d`.`id` = `c`.`desc_id`))) order by `c`.`time` desc,`c`.`code`,`c`.`new_code`;

SET FOREIGN_KEY_CHECKS = 1;

0 comments on commit aba62ff

Please sign in to comment.