From 4cab9b2f36a6c10990e010e348f2ce17e11e5c96 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 1 Sep 2019 16:10:30 +1000 Subject: [PATCH] fix foreign key errors --- setup.sql | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/setup.sql b/setup.sql index ca7b948..740c81e 100644 --- a/setup.sql +++ b/setup.sql @@ -9,12 +9,18 @@ CREATE TABLE IF NOT EXISTS `contact_settings` ( `fetch` ENUM('always', 'once', 'never') DEFAULT 'once', `submit` ENUM('always', 'once', 'never') DEFAULT 'once', `generation` ENUM('always', 'once', 'never') DEFAULT 'once', - `reply` ENUM('always', 'once', 'never') DEFAULT 'once' - FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE, + `reply` ENUM('always', 'once', 'never') DEFAULT 'once', + FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE +) ENGINE=INNODB; +CREATE TABLE IF NOT EXISTS `credentials` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `client_id` VARCHAR(128) NOT NULL, + `client_secret` VARCHAR(128) NOT NULL, + `secret` VARCHAR(128) NOT NULL ) ENGINE=INNODB; CREATE TABLE IF NOT EXISTS `bots` ( `id` BINARY(64) PRIMARY KEY, - `user_id` BINARY(64) PRIMARY KEY, + `user_id` BINARY(64) NOT NULL, `credentials_id` INT NOT NULL, `enabled` BOOLEAN DEFAULT 1, `replies_enabled` BOOLEAN DEFAULT 1, @@ -31,12 +37,6 @@ CREATE TABLE IF NOT EXISTS `bots` ( FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (`credentials_id`) REFERENCES credentials(id) ON DELETE CASCADE ) ENGINE=INNODB; -CREATE TABLE IF NOT EXISTS `credentials` ( - `id` INT AUTO_INCREMENT PRIMARY KEY, - `client_id` VARCHAR(128) NOT NULL, - `client_secret` VARCHAR(128) NOT NULL, - `secret` VARCHAR(128) NOT NULL -) ENGINE=INNODB; CREATE TABLE IF NOT EXISTS `fedi_account` ( `handle` VARCHAR(128) NOT NULL PRIMARY KEY, `outbox` VARCHAR(256), @@ -55,14 +55,14 @@ CREATE TABLE IF NOT EXISTS `word_blacklist` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `bot_id` BINARY(64) NOT NULL, `phrase` VARCHAR(128) NOT NULL, - `whole_word` BOOLEAN NOT NULL - FOREIGN KEY (`bot_id`) REFERENCES bots(id) ON DELETE CASCADE, + `whole_word` BOOLEAN NOT NULL, + FOREIGN KEY (`bot_id`) REFERENCES bots(id) ON DELETE CASCADE ) ENGINE=INNODB; CREATE TABLE IF NOT EXISTS `contact_history` ( `user_id` BINARY(64) NOT NULL, `fetch` BOOLEAN DEFAULT 0, `submit` BOOLEAN DEFAULT 0, `generation` BOOLEAN DEFAULT 0, - `reply` BOOLEAN DEFAULT 0 - FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE, + `reply` BOOLEAN DEFAULT 0, + FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=INNODB;