-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
31 lines (27 loc) · 803 Bytes
/
Copy pathschema.sql
File metadata and controls
31 lines (27 loc) · 803 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
CREATE TABLE IF NOT EXISTS repo (
repo_id BIGINT PRIMARY KEY,
owner TEXT NOT NULL,
name TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS branches (
branch_id SERIAL PRIMARY KEY,
repo_id BIGINT REFERENCES repo(repo_id) ON DELETE CASCADE,
name TEXT NOT NULL,
sha TEXT NOT NULL,
is_main BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (repo_id, name)
);
CREATE TABLE IF NOT EXISTS commits (
commit_id SERIAL PRIMARY KEY,
repo_id BIGINT REFERENCES repo(repo_id) ON DELETE CASCADE,
sha TEXT NOT NULL,
committed_at TIMESTAMP NOT NULL,
UNIQUE (repo_id, sha)
);
CREATE TABLE IF NOT EXISTS pulls (
pull_id BIGINT PRIMARY KEY,
repo_id BIGINT REFERENCES repo(repo_id) ON DELETE CASCADE,
merged BOOLEAN,
created_at TIMESTAMP,
merged_at TIMESTAMP
);