be more specific on table creation

This commit is contained in:
Christian Staudte 2020-11-03 22:41:40 +01:00
parent 7fda8339f4
commit 2ab458f044
Signed by: christian.staudte
GPG key ID: 88ED5070FE0D5F23

View file

@ -1,16 +1,17 @@
CREATE TABLE IF NOT EXISTS events ( CREATE TABLE IF NOT EXISTS `events` (
id INT AUTO_INCREMENT PRIMARY KEY, `id` int(11) NOT NULL AUTO_INCREMENT,
token VARCHAR(36) NOT NULL, `token` varchar(36) NOT NULL,
UNIQUE(token) PRIMARY KEY (`id`),
) ENGINE=INNODB; UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS hashes ( CREATE TABLE IF NOT EXISTS `hashes` (
id INT AUTO_INCREMENT PRIMARY KEY, `id` int(11) NOT NULL AUTO_INCREMENT,
event INT NOT NULL, `event` int(11) NOT NULL,
FOREIGN KEY(event) REFERENCES events(id) `vote_round` int(11) NOT NULL,
ON DELETE CASCADE, `name` varchar(128) NOT NULL,
vote_round INT NOT NULL, `hash` varchar(128) DEFAULT NULL,
name VARCHAR(128) NOT NULL, PRIMARY KEY (`id`),
hash VARCHAR(128) NULL, UNIQUE KEY `event` (`event`,`vote_round`,`name`),
UNIQUE(event, vote_round, name) CONSTRAINT `hashes_ibfk_1` FOREIGN KEY (`event`) REFERENCES `events` (`id`) ON DELETE CASCADE
); ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;