aboutsummaryrefslogtreecommitdiff
path: root/captain/sql
diff options
context:
space:
mode:
Diffstat (limited to 'captain/sql')
-rw-r--r--captain/sql/create.sql7
1 files changed, 5 insertions, 2 deletions
diff --git a/captain/sql/create.sql b/captain/sql/create.sql
index 7517e07..40cbc0c 100644
--- a/captain/sql/create.sql
+++ b/captain/sql/create.sql
@@ -15,10 +15,13 @@ CREATE TABLE group_instructions(group_id INTEGER, instruction INTEGER, player IN
CREATE TABLE checkin(player INTEGER PRIMARY KEY, year INTEGER, month INTEGER, day INTEGER, hour INTEGER, minute INTEGER, second INTEGER, os TEXT DEFAULT NULL, FOREIGN KEY(player) REFERENCES players(id) ON DELETE CASCADE);
-CREATE TABLE schedule(instruction INTEGER NOT NULL, player INTEGER NOT NULL, day INTEGER DEFAULT 0, hour INTEGER DEFAULT 0, FOREIGN KEY(instruction) REFERENCES instructions(id) ON DELETE CASCADE, FOREIGN KEY(player) REFERENCES players(id) ON DELETE CASCADE );
+CREATE TABLE schedule(id INTEGER PRIMARY KEY, instruction INTEGER NOT NULL, player INTEGER NOT NULL, day INTEGER DEFAULT 0, hour INTEGER DEFAULT 0, FOREIGN KEY(instruction) REFERENCES instructions(id) ON DELETE CASCADE, FOREIGN KEY(player) REFERENCES players(id) ON DELETE CASCADE );
+
+CREATE TABLE scheduled_jobs(schedule INTEGER UNIQUE NOT NULL, job INTEGER UNIQUE NOT NULL, FOREIGN KEY(schedule) REFERENCES schedules(id) ON DELETE CASCADE, FOREIGN KEY(job) REFERENCES jobs(id));
CREATE TABLE users(id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE NOT NULL, email TEXT NOT NULL, password TEXT NOT NULL, level INTEGER DEFAULT 1);
-CREATE TABLE sessions(user INTEGER, session TEXT NOT NULL, expiration TEXT NOT NULL, FOREIGN KEY(user) REFERENCES users(id) ON DELETE CASCADE);
+CREATE TABLE sessions(user INTEGER, session TEXT NOT NULL, accessed TEXT NOT NULL, FOREIGN KEY(user) REFERENCES users(id) ON DELETE CASCADE);
CREATE VIEW session_auth AS SELECT sessions.session, users.username, users.level FROM sessions INNER JOIN users ON sessions.user = users.id;
+