stationslauf/migration.sql
Philipp Hofer 5cbdedc37c
All checks were successful
CI/CD Pipeline / test (push) Successful in 13m45s
CI/CD Pipeline / deploy (push) Successful in 6m4s
properly end station run; every team gets a station
2025-04-22 12:21:01 +02:00

65 lines
1.7 KiB
SQL

CREATE TABLE IF NOT EXISTS station (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
notes TEXT,
amount_people INTEGER,
last_login DATETIME,
ready BOOLEAN NOT NULL DEFAULT false,
pw TEXT NOT NULL,
lat REAL,
lng REAL
);
CREATE TABLE IF NOT EXISTS route (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE -- e.g. 'wiwö'
);
CREATE TABLE IF NOT EXISTS route_station (
route_id INTEGER NOT NULL,
station_id INTEGER NOT NULL,
pos INTEGER NOT NULL,
PRIMARY KEY (route_id, station_id),
FOREIGN KEY (route_id) REFERENCES route(id),
FOREIGN KEY (station_id) REFERENCES station(id)
);
CREATE TABLE IF NOT EXISTS team (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
notes TEXT,
amount_people INTEGER,
first_station_id INTEGER NOT NULL,
last_station_id INTEGER,
route_id INTEGER NOT NULL,
FOREIGN KEY (first_station_id) REFERENCES station(id),
FOREIGN KEY (last_station_id) REFERENCES station(id),
FOREIGN KEY (route_id) REFERENCES route(id)
);
CREATE TABLE IF NOT EXISTS rating (
team_id INTEGER NOT NULL,
station_id INTEGER NOT NULL,
points INTEGER,
notes TEXT,
arrived_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
started_at DATETIME,
left_at DATETIME,
PRIMARY KEY (team_id, station_id),
FOREIGN KEY (team_id) REFERENCES team(id),
FOREIGN KEY (station_id) REFERENCES station(id)
);
CREATE TABLE IF NOT EXISTS user (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL UNIQUE,
pw TEXT NOT NULL,
require_new_password_code TEXT
);
CREATE TABLE IF NOT EXISTS tower_sessions (
id TEXT PRIMARY KEY NOT NULL,
data BLOB NOT NULL,
expiry_date INTEGER NOT NULL
);