forked from hasura-imad/imad-2016-app
-
Notifications
You must be signed in to change notification settings - Fork 58
/
schema.sql
145 lines (102 loc) · 2.8 KB
/
schema.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
--
-- Name: article; Type: TABLE; Schema: public; Owner: coco98
--
CREATE TABLE article (
id integer NOT NULL,
title text NOT NULL,
heading text NOT NULL,
date date NOT NULL,
content text NOT NULL
);
--
-- Name: article_id_seq; Type: SEQUENCE; Schema: public; Owner: coco98
--
CREATE SEQUENCE article_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: comment; Type: TABLE; Schema: public; Owner: coco98
--
CREATE TABLE comment (
id integer NOT NULL,
article_id integer NOT NULL,
user_id integer NOT NULL,
comment text NOT NULL,
"timestamp" timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: comment_id_seq; Type: SEQUENCE; Schema: public; Owner: coco98
--
CREATE SEQUENCE comment_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: user; Type: TABLE; Schema: public; Owner: coco98
--
CREATE TABLE "user" (
id integer NOT NULL,
username text NOT NULL,
password text NOT NULL
);
--
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: coco98
--
CREATE SEQUENCE user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY article ALTER COLUMN id SET DEFAULT nextval('article_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY comment ALTER COLUMN id SET DEFAULT nextval('comment_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY "user" ALTER COLUMN id SET DEFAULT nextval('user_id_seq'::regclass);
--
-- Name: article_id; Type: CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY article
ADD CONSTRAINT article_id PRIMARY KEY (id);
--
-- Name: article_title; Type: CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY article
ADD CONSTRAINT article_title UNIQUE (title);
--
-- Name: comment_id; Type: CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY comment
ADD CONSTRAINT comment_id PRIMARY KEY (id);
--
-- Name: user_id; Type: CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_id PRIMARY KEY (id);
--
-- Name: user_username; Type: CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY "user"
ADD CONSTRAINT user_username UNIQUE (username);
--
-- Name: comment_article_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY comment
ADD CONSTRAINT comment_article_id_fkey FOREIGN KEY (article_id) REFERENCES article(id);
--
-- Name: comment_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: coco98
--
ALTER TABLE ONLY comment
ADD CONSTRAINT comment_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);