-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
36 lines (30 loc) · 870 Bytes
/
schema.sql
File metadata and controls
36 lines (30 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
PRAGMA journal_mode=WAL;
PRAGMA foreign_keys=ON;
PRAGMA strict=ON;
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
email TEXT UNIQUE,
passhash TEXT NOT NULL,
first_name TEXT NOT NULL,
profile_picture TEXT
);
CREATE TABLE IF NOT EXISTS sessions (
token TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
expiration INTEGER NOT NULL
);
DROP TABLE IF EXISTS flight_responses;
CREATE TABLE IF NOT EXISTS layovers (
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
iata_code TEXT NOT NULL,
arrive TEXT NOT NULL,
depart TEXT NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS layovers_unique_idx
ON layovers(user_id, iata_code, arrive, depart);
CREATE TABLE IF NOT EXISTS assets (
hash TEXT PRIMARY KEY,
name TEXT NOT NULL,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
data BLOB NOT NULL
);