-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
269 lines (186 loc) · 7.25 KB
/
schema.sql
File metadata and controls
269 lines (186 loc) · 7.25 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.13 (Debian 15.13-1.pgdg120+1)
-- Dumped by pg_dump version 15.13 (Debian 15.13-1.pgdg120+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- Name: users_role_enum; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.users_role_enum AS ENUM (
'user',
'admin',
'superadmin',
'test'
);
ALTER TYPE public.users_role_enum OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: comments; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.comments (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
content text NOT NULL,
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL,
"userId" uuid NOT NULL,
"postId" uuid NOT NULL,
"parentId" uuid,
likes integer DEFAULT 0 NOT NULL,
"fileUrl" character varying,
"fileType" character varying,
"fileName" character varying,
"imageUrl" character varying,
"likedUserIds" text DEFAULT ''::text NOT NULL,
"repliesCount" integer DEFAULT 0 NOT NULL,
"numericId" character varying,
slug character varying NOT NULL
);
ALTER TABLE public.comments OWNER TO postgres;
--
-- Name: posts; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.posts (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
content text NOT NULL,
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL,
"userId" uuid NOT NULL,
likes integer DEFAULT 0 NOT NULL,
"fileUrl" character varying,
"fileType" character varying,
"fileName" character varying,
"likedUserIds" text DEFAULT ''::text NOT NULL,
"repliesCount" integer DEFAULT 0 NOT NULL,
"imageUrl" character varying,
slug character varying NOT NULL
);
ALTER TABLE public.posts OWNER TO postgres;
--
-- Name: user_following; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.user_following (
"userId" uuid NOT NULL,
"followingId" uuid NOT NULL
);
ALTER TABLE public.user_following OWNER TO postgres;
--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
email character varying NOT NULL,
"userName" character varying NOT NULL,
"passwordHash" character varying NOT NULL,
"avatarUrl" character varying,
"avatarShape" character varying DEFAULT 'circle'::character varying NOT NULL,
role public.users_role_enum DEFAULT 'user'::public.users_role_enum NOT NULL,
slug character varying NOT NULL,
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
);
ALTER TABLE public.users OWNER TO postgres;
--
-- Name: posts PK_2829ac61eff60fcec60d7274b9e; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.posts
ADD CONSTRAINT "PK_2829ac61eff60fcec60d7274b9e" PRIMARY KEY (id);
--
-- Name: user_following PK_6cc28fa2a68c13314be6cfd86c6; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_following
ADD CONSTRAINT "PK_6cc28fa2a68c13314be6cfd86c6" PRIMARY KEY ("userId", "followingId");
--
-- Name: comments PK_8bf68bc960f2b69e818bdb90dcb; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comments
ADD CONSTRAINT "PK_8bf68bc960f2b69e818bdb90dcb" PRIMARY KEY (id);
--
-- Name: users PK_a3ffb1c0c8416b9fc6f907b7433; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY (id);
--
-- Name: users UQ_226bb9aa7aa8a69991209d58f59; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "UQ_226bb9aa7aa8a69991209d58f59" UNIQUE ("userName");
--
-- Name: comments UQ_52677ce5ac41f678869b5cd33a5; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comments
ADD CONSTRAINT "UQ_52677ce5ac41f678869b5cd33a5" UNIQUE (slug);
--
-- Name: posts UQ_54ddf9075260407dcfdd7248577; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.posts
ADD CONSTRAINT "UQ_54ddf9075260407dcfdd7248577" UNIQUE (slug);
--
-- Name: users UQ_97672ac88f789774dd47f7c8be3; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE (email);
--
-- Name: users UQ_bc0c27d77ee64f0a097a5c269b3; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT "UQ_bc0c27d77ee64f0a097a5c269b3" UNIQUE (slug);
--
-- Name: IDX_06680b0cdf84b1d8a690e22176; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "IDX_06680b0cdf84b1d8a690e22176" ON public.user_following USING btree ("userId");
--
-- Name: IDX_b88ad49e84034c506d3c0ae742; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX "IDX_b88ad49e84034c506d3c0ae742" ON public.user_following USING btree ("followingId");
--
-- Name: user_following FK_06680b0cdf84b1d8a690e221763; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_following
ADD CONSTRAINT "FK_06680b0cdf84b1d8a690e221763" FOREIGN KEY ("userId") REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- Name: comments FK_7e8d7c49f218ebb14314fdb3749; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comments
ADD CONSTRAINT "FK_7e8d7c49f218ebb14314fdb3749" FOREIGN KEY ("userId") REFERENCES public.users(id);
--
-- Name: comments FK_8770bd9030a3d13c5f79a7d2e81; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comments
ADD CONSTRAINT "FK_8770bd9030a3d13c5f79a7d2e81" FOREIGN KEY ("parentId") REFERENCES public.comments(id) ON DELETE CASCADE;
--
-- Name: posts FK_ae05faaa55c866130abef6e1fee; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.posts
ADD CONSTRAINT "FK_ae05faaa55c866130abef6e1fee" FOREIGN KEY ("userId") REFERENCES public.users(id);
--
-- Name: user_following FK_b88ad49e84034c506d3c0ae7422; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.user_following
ADD CONSTRAINT "FK_b88ad49e84034c506d3c0ae7422" FOREIGN KEY ("followingId") REFERENCES public.users(id);
--
-- Name: comments FK_e44ddaaa6d058cb4092f83ad61f; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.comments
ADD CONSTRAINT "FK_e44ddaaa6d058cb4092f83ad61f" FOREIGN KEY ("postId") REFERENCES public.posts(id);
--
-- PostgreSQL database dump complete
--