-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
46 lines (38 loc) · 1.51 KB
/
schema.sql
File metadata and controls
46 lines (38 loc) · 1.51 KB
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
37
38
39
40
41
42
43
44
45
46
CREATE TABLE IF NOT EXISTS submissions (
id SERIAL PRIMARY KEY,
submitted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
ip_address TEXT,
user_agent TEXT,
referer TEXT,
status TEXT NOT NULL DEFAULT 'new' CHECK (status IN ('new','in_progress','complete','archived')),
file_path TEXT,
comment TEXT,
form_data JSONB NOT NULL
);
CREATE INDEX IF NOT EXISTS submissions_status_submitted_at_idx
ON submissions (status, submitted_at DESC);
CREATE INDEX IF NOT EXISTS submissions_submitted_at_idx
ON submissions (submitted_at DESC);
CREATE TABLE IF NOT EXISTS admin_users (
username TEXT PRIMARY KEY,
password_hash TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Default admin user; change this password immediately via the dashboard.
INSERT INTO admin_users (username, password_hash)
VALUES ('admin', '$2b$12$R3PN9SNYhLYD3ruOZ3qMJ.gnIK8POtoTLbHKni/mc1C.Y9hDpoteu')
ON CONFLICT (username) DO NOTHING;
CREATE TABLE IF NOT EXISTS admin_defaults (
key TEXT PRIMARY KEY,
value TEXT NOT NULL
);
INSERT INTO admin_defaults (key, value)
VALUES ('admin_default_password_hash', '$2b$12$R3PN9SNYhLYD3ruOZ3qMJ.gnIK8POtoTLbHKni/mc1C.Y9hDpoteu')
ON CONFLICT (key) DO NOTHING;
CREATE TABLE IF NOT EXISTS submission_blocks (
scope TEXT NOT NULL CHECK (scope IN ('ip','global')),
identifier TEXT NOT NULL,
blocked_until TIMESTAMPTZ NOT NULL,
PRIMARY KEY (scope, identifier)
);
CREATE INDEX IF NOT EXISTS submission_blocks_until_idx ON submission_blocks (blocked_until);