-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sql
29 lines (26 loc) · 827 Bytes
/
init.sql
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
CREATE TABLE "user"
(
id bigint PRIMARY KEY
);
CREATE TABLE segment
(
id bigserial PRIMARY KEY,
slug text NOT NULL UNIQUE
);
CREATE TABLE experiment
(
user_id bigserial,
segment_id bigserial,
expire_at timestamp(0) with time zone,
PRIMARY KEY (user_id, segment_id),
FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE,
FOREIGN KEY (segment_id) REFERENCES segment(id) ON DELETE CASCADE
);
CREATE TABLE report
(
id bigserial PRIMARY KEY,
user_id bigserial,
segment_slug text NOT NULL,
action text NOT NULL,
date timestamp(0) with time zone NOT NULL DEFAULT NOW()
)