From 6572f20b932bae1cecd3a27677f36c747643e64e Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 14 Mar 2020 19:50:49 +0100 Subject: [PATCH] Align db setup to dumped values --- sql/setup-database.sql | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sql/setup-database.sql b/sql/setup-database.sql index 37a0e4b..1005723 100644 --- a/sql/setup-database.sql +++ b/sql/setup-database.sql @@ -2,20 +2,22 @@ CREATE DATABASE friendsbook; USE friendsbook; -CREATE TABLE `tans` ( - `id` INT NOT NULL AUTO_INCREMENT, - `tan` VARCHAR(13) NOT NULL, - `used` BOOLEAN NOT NULL, - PRIMARY KEY (`id`) -) ENGINE = InnoDB; - CREATE TABLE `user` ( `ID` INT NOT NULL AUTO_INCREMENT, - `user` VARCHAR(50) NOT NULL DEFAULT '0', + `username` VARCHAR(50) NOT NULL DEFAULT '0', `email` VARCHAR(100) NOT NULL DEFAULT '0', `password` VARCHAR(100) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), - UNIQUE INDEX `user` (`user`) + UNIQUE INDEX `user`(`username`) +) ENGINE = InnoDB; + +CREATE TABLE `tans` ( + `id` INT NOT NULL AUTO_INCREMENT, + `userID` INT NOT NULL, + `tan` VARCHAR(13) NOT NULL, + `used` BOOLEAN NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB; CREATE TABLE `entries` (