-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructure.sql
38 lines (34 loc) · 1.09 KB
/
structure.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
30
31
32
33
34
35
36
37
38
CREATE SCHEMA github;
CREATE TABLE github.issue (
"id" bigint PRIMARY KEY,
"title" text NOT NULL,
"number" integer NOT NULL,
"state" character varying(10) NOT NULL,
"body" text,
"created_by" character varying(64) NOT NULL,
"url" character varying(255) NOT NULL,
"created_at" date NOT NULL,
"updated_at" date,
"closed_at" date
);
CREATE TABLE github.issue_comment (
"id" bigint PRIMARY KEY,
"issue_id" integer,
"body" text,
"created_by" character varying(64) NOT NULL,
"created_at" date NOT NULL,
"updated_at" date,
"url" character varying(255) UNIQUE NOT NULL,
CONSTRAINT fk_issue FOREIGN KEY(issue_id) REFERENCES github.issue(id)
);
CREATE TABLE github.label (
"id" bigint NOT NULL PRIMARY KEY,
"label" character varying(64) UNIQUE NOT NULL
);
CREATE TABLE github.issue_label (
"label_id" bigint NOT NULL,
"issue_id" bigint NOT NULL,
PRIMARY KEY(label_id, issue_id),
CONSTRAINT fk_issue FOREIGN KEY(issue_id) REFERENCES github.issue(id),
CONSTRAINT fk_label FOREIGN KEY(label_id) REFERENCES github.label(id)
)