From df240c2394bd43fd901e2de1cf4c16d44d989dd2 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 7 Jun 2023 11:45:58 +0200 Subject: [PATCH] Fix database migration order --- .../migrations/mysql/01_init-schema.up.sql | 16 +++++++++------- .../migrations/sqlite3/01_init-schema.up.sql | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/internal/repository/migrations/mysql/01_init-schema.up.sql b/internal/repository/migrations/mysql/01_init-schema.up.sql index d3369fc..3a6930c 100644 --- a/internal/repository/migrations/mysql/01_init-schema.up.sql +++ b/internal/repository/migrations/mysql/01_init-schema.up.sql @@ -48,13 +48,6 @@ CREATE TABLE IF NOT EXISTS jobtag ( FOREIGN KEY (job_id) REFERENCES job (id) ON DELETE CASCADE, FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE); -CREATE TABLE IF NOT EXISTS configuration ( - username varchar(255), - confkey varchar(255), - value varchar(255), - PRIMARY KEY (username, confkey), - FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); - CREATE TABLE IF NOT EXISTS user ( username varchar(255) PRIMARY KEY NOT NULL, password varchar(255) DEFAULT NULL, @@ -62,3 +55,12 @@ CREATE TABLE IF NOT EXISTS user ( name varchar(255) DEFAULT NULL, roles varchar(255) NOT NULL DEFAULT "[]", email varchar(255) DEFAULT NULL); + +CREATE TABLE IF NOT EXISTS configuration ( + username varchar(255), + confkey varchar(255), + value varchar(255), + PRIMARY KEY (username, confkey), + FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); + + diff --git a/internal/repository/migrations/sqlite3/01_init-schema.up.sql b/internal/repository/migrations/sqlite3/01_init-schema.up.sql index 646fa69..a3aa4ae 100644 --- a/internal/repository/migrations/sqlite3/01_init-schema.up.sql +++ b/internal/repository/migrations/sqlite3/01_init-schema.up.sql @@ -42,13 +42,6 @@ PRIMARY KEY (job_id, tag_id), FOREIGN KEY (job_id) REFERENCES job (id) ON DELETE CASCADE, FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE); -CREATE TABLE IF NOT EXISTS configuration ( -username varchar(255), -confkey varchar(255), -value varchar(255), -PRIMARY KEY (username, confkey), -FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); - CREATE TABLE IF NOT EXISTS user ( username varchar(255) PRIMARY KEY NOT NULL, password varchar(255) DEFAULT NULL, @@ -56,3 +49,12 @@ ldap tinyint NOT NULL DEFAULT 0, /* col called "ldap" for historic reas name varchar(255) DEFAULT NULL, roles varchar(255) NOT NULL DEFAULT "[]", email varchar(255) DEFAULT NULL); + +CREATE TABLE IF NOT EXISTS configuration ( +username varchar(255), +confkey varchar(255), +value varchar(255), +PRIMARY KEY (username, confkey), +FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION); + +