-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sql
More file actions
34 lines (28 loc) · 1.35 KB
/
Copy pathsetup.sql
File metadata and controls
34 lines (28 loc) · 1.35 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
-- To be run in supabase on prefrebly a new database to avoid any issues
CREATE TABLE IF NOT EXISTS events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
code TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
date_type TEXT NOT NULL CHECK (date_type IN ('specific', 'days')),
dates TEXT[] NOT NULL,
start_hour INTEGER NOT NULL CHECK (start_hour >= 0 AND start_hour <= 23),
end_hour INTEGER NOT NULL CHECK (end_hour >= 1 AND end_hour <= 24),
admin_password_hash TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE IF NOT EXISTS participants (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
event_id UUID NOT NULL REFERENCES events(id) ON DELETE CASCADE,
name TEXT NOT NULL,
password_hash TEXT,
availability TEXT[] NOT NULL DEFAULT '{}',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX IF NOT EXISTS participants_event_name
ON participants (event_id, name);
CREATE INDEX IF NOT EXISTS participants_event_id
ON participants (event_id);
CREATE INDEX IF NOT EXISTS events_code
ON events (code);
ALTER TABLE events DISABLE ROW LEVEL SECURITY;
ALTER TABLE participants DISABLE ROW LEVEL SECURITY;