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
1 changed files with 16 additions and 15 deletions

View File

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