-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers_posts.sql
697 lines (530 loc) · 25 KB
/
users_posts.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
--
-- PostgreSQL database dump
--
-- Dumped from database version 16rc1
-- Dumped by pg_dump version 16rc1
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: bookmarks_list; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA bookmarks_list;
ALTER SCHEMA bookmarks_list OWNER TO postgres;
--
-- Name: comments_list; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA comments_list;
ALTER SCHEMA comments_list OWNER TO postgres;
--
-- Name: likes_list; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA likes_list;
ALTER SCHEMA likes_list OWNER TO postgres;
--
-- Name: posts_list; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA posts_list;
ALTER SCHEMA posts_list OWNER TO postgres;
--
-- Name: dblink; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
--
-- Name: EXTENSION dblink; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION dblink IS 'connect to other PostgreSQL databases from within a database';
--
-- Name: fetch_comment_bookmarks(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_comment_bookmarks(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(user_id text)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select f.user_id as user_id from bookmarks_list.comments as f
where comment_id = $1 and not is_muted_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user(f.user_id, $2, username, ip, port, password)
and is_exists_user($2, f.user_id, username, ip, port, password)
and not is_private_user($2, f.user_id, username, ip, port, password)
offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_comment_bookmarks(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_comment_comments(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_comment_comments(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select row_to_json(p) as post_data from comments_list.comments_data as p
where p.parent_post_id = $1 and p.deleted = false
and not is_muted_user($2, p.sender, username, ip, port, password)
and not is_blocked_user($2, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $2, username, ip, port, password)
and not is_private_user($2, p.sender, username, ip, port, password)
and is_exists_user($2, p.sender, username, ip, port, password)
order by p.upload_time desc offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_comment_comments(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_comment_engagements(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_comment_engagements(currentid text, commentid text) RETURNS TABLE(liked_by_current_id boolean, likes_count integer, bookmarked_by_current_id boolean, bookmarks_count integer, comments_count integer)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select
exists (select 1 from likes_list.comments where user_id = $1 and comment_id = $2) as liked_by_current_id,
(select count(*)::integer from likes_list.comments where comment_id = $2) as likes_count,
exists (select 1 from bookmarks_list.comments where user_id = $1 and comment_id = $2) as bookmarked_by_current_id,
(select count(*)::integer from bookmarks_list.comments where comment_id = $2) as bookmarks_count,
(select count(*)::integer from comments_list.comments_data where parent_post_id = $2 and deleted = false) as comments_count
;
end;
$_$;
ALTER FUNCTION public.fetch_comment_engagements(currentid text, commentid text) OWNER TO postgres;
--
-- Name: fetch_comment_likes(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_comment_likes(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(user_id text)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select f.user_id as user_id from likes_list.comments as f
where comment_id = $1 and not is_muted_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user(f.user_id, $2, username, ip, port, password)
and is_exists_user($2, f.user_id, username, ip, port, password)
and not is_private_user($2, f.user_id, username, ip, port, password)
offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_comment_likes(commentid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_feed(text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_feed(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
return query select fetched_post_data as post_data from
(
select row_to_json(p) as fetched_post_data, upload_time from posts_list.posts_data as p
inner join dblink(users_profiles_path, 'select * from follow_users.follow_history')
f(following_id text, followed_id text, follow_time text) on following_id = $1
where p.sender = followed_id and p.deleted = false
and not is_muted_user($1, p.sender, username, IP, PORT, password)
union all
select row_to_json(p) as fetched_post_data, upload_time from posts_list.posts_data as p
where p.sender = $1 and p.deleted = false
union all
select row_to_json(p) as fetched_post_data, upload_time from comments_list.comments_data as p
inner join dblink(users_profiles_path, 'select * from follow_users.follow_history')
f(following_id text, followed_id text, follow_time text) on following_id = $1
where p.sender = followed_id and p.deleted = false
and not is_muted_user($1, p.sender, username, IP, PORT, password)
union all
select row_to_json(p) as fetched_post_data, upload_time from comments_list.comments_data as p
where p.sender = $1 and p.deleted = false
) as res order by res.upload_time desc offset $2 limit $3;
end;
$_$;
ALTER FUNCTION public.fetch_feed(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_most_popular_posts(text, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_most_popular_posts(currentid text, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query
SELECT row_to_json(p) from likes_list.posts as l
inner join posts_list.posts_data p on p.post_id = l.post_id
where not is_muted_user($1, p.sender, username, IP, PORT, password)
and not is_blocked_user($1, p.sender, username, IP, PORT, password)
and not is_blocked_user(p.sender, $1, username, IP, PORT, password)
and is_exists_user($1, p.sender, username, IP, PORT, password)
group by p.post_id
order by count(l.post_id) desc offset 0 limit $2
;
end;
$_$;
ALTER FUNCTION public.fetch_most_popular_posts(currentid text, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_post_bookmarks(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_post_bookmarks(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(user_id text)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select f.user_id as user_id from bookmarks_list.posts as f
where post_id = $1 and not is_muted_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user(f.user_id, $2, username, ip, port, password)
and is_exists_user($2, f.user_id, username, ip, port, password)
and not is_private_user($2, f.user_id, username, ip, port, password)
offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_post_bookmarks(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_post_comments(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_post_comments(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select row_to_json(p) as post_data from comments_list.comments_data as p
where p.parent_post_id = $1 and p.deleted = false
and not is_muted_user($2, p.sender, username, ip, port, password)
and not is_blocked_user($2, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $2, username, ip, port, password)
and not is_private_user($2, p.sender, username, ip, port, password)
and is_exists_user($2, p.sender, username, ip, port, password)
order by p.upload_time desc offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_post_comments(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_post_engagements(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_post_engagements(currentid text, postid text) RETURNS TABLE(liked_by_current_id boolean, likes_count integer, bookmarked_by_current_id boolean, bookmarks_count integer, comments_count integer)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select
exists (select 1 from likes_list.posts where user_id = $1 and post_id = $2) as liked_by_current_id,
(select count(*)::integer from likes_list.posts where post_id = $2) as likes_count,
exists (select 1 from bookmarks_list.posts where user_id = $1 and post_id = $2) as bookmarked_by_current_id,
(select count(*)::integer from bookmarks_list.posts where post_id = $2) as bookmarks_count,
(select count(*)::integer from comments_list.comments_data where parent_post_id = $2 and deleted = false) as comments_count
;
end;
$_$;
ALTER FUNCTION public.fetch_post_engagements(currentid text, postid text) OWNER TO postgres;
--
-- Name: fetch_post_likes(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_post_likes(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(user_id text)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select f.user_id as user_id from likes_list.posts as f
where post_id = $1 and not is_muted_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user($2, f.user_id, username, ip, port, password)
and not is_blocked_user(f.user_id, $2, username, ip, port, password)
and is_exists_user($2, f.user_id, username, ip, port, password)
and not is_private_user($2, f.user_id, username, ip, port, password)
offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_post_likes(postid text, currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_searched_comments(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_searched_comments(currentid text, searchedtext text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select row_to_json(p) as post_data from comments_list.comments_data as p
where lower(p.content) like '%' || lower($2) || '%' and not is_muted_user($1, p.sender, username, ip, port, password)
and not is_blocked_user($1, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $1, username, ip, port, password)
and not is_private_user($1, p.sender, username, ip, port, password)
and is_exists_user($1, p.sender, username, ip, port, password)
and p.deleted = false
order by p.upload_time desc offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_searched_comments(currentid text, searchedtext text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_searched_posts(text, text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_searched_posts(currentid text, searchedtext text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select row_to_json(p) as post_data from posts_list.posts_data as p
where lower(p.content) like '%' || lower($2) || '%' and not is_muted_user($1, p.sender, username, ip, port, password)
and not is_blocked_user($1, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $1, username, ip, port, password)
and not is_private_user($1, p.sender, username, ip, port, password)
and is_exists_user($1, p.sender, username, ip, port, password)
and p.deleted = false
order by p.upload_time desc offset $3 limit $4;
end;
$_$;
ALTER FUNCTION public.fetch_searched_posts(currentid text, searchedtext text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: fetch_user_bookmarks(text, integer, integer, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.fetch_user_bookmarks(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) RETURNS TABLE(post_data json)
LANGUAGE plpgsql
AS $_$
declare
begin
return query select fetched_post_data as post_data from
(
select row_to_json(f) as fetched_post_data, bookmarked_time from bookmarks_list.posts as p
inner join posts_list.posts_data f(
post_id, type, content, sender, upload_time, medias_datas, deleted
) on f.post_id = p.post_id
where p.user_id = $1 and not is_muted_user($1, p.sender, username, ip, port, password)
and not is_blocked_user($1, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $1, username, ip, port, password)
and not is_private_user($1, p.sender, username, ip, port, password)
and is_exists_user($1, p.sender, username, ip, port, password) and f.deleted = false
union all
select row_to_json(f) as fetched_post_data, bookmarked_time from bookmarks_list.comments as p
inner join comments_list.comments_data f(
comment_id, type, content, sender, upload_time, medias_datas, parent_post_type,
parent_post_id, parent_post_sender, deleted
) on f.comment_id = p.comment_id
where p.user_id = $1 and not is_muted_user($1, p.sender, username, ip, port, password)
and not is_blocked_user($1, p.sender, username, ip, port, password)
and not is_blocked_user(p.sender, $1, username, ip, port, password)
and not is_private_user($1, p.sender, username, ip, port, password)
and is_exists_user($1, p.sender, username, ip, port, password) and f.deleted = false
) as res order by res.bookmarked_time desc offset $2 limit $3;
end;
$_$;
ALTER FUNCTION public.fetch_user_bookmarks(currentid text, currentlength integer, paginationlimit integer, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_blocked_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_blocked_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return false; end if;
select exists (
select * from dblink(users_profiles_path, 'select * from blocked_users.block_history') as b(user_id text, blocked_id text)
where b.user_id = $1 and b.blocked_id = $2
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_blocked_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_exists_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_exists_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return true; end if;
select exists (
select * from dblink(users_profiles_path, 'select user_id, deleted, suspended from basic_data.user_profile') as pr(user_id text, deleted bool, suspended bool)
where pr.user_id = $2 and pr.deleted = false and pr.suspended = false
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_exists_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_muted_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_muted_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return false; end if;
select exists (
select * from dblink(users_profiles_path, 'select * from muted_users.mute_history') as m(user_id text, muted_id text)
where m.user_id = $1 and m.muted_id = $2
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_muted_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
--
-- Name: is_private_user(text, text, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public.is_private_user(checkingid text, checkedid text, username text, ip text, port integer, password text) RETURNS boolean
LANGUAGE plpgsql
AS $_$
declare
res bool;
users_profiles_path text := 'dbname=users_profiles user='||username||' hostaddr='||ip||' port='||port||' password='||password;
begin
if checkingid = checkedid then return false; end if;
select exists (
select * from dblink(users_profiles_path, 'select user_id, private from basic_data.user_profile') as pr(user_id text, private bool)
where pr.user_id = $2 and pr.private = true
) into res;
if res = false then return false; end if;
select not exists (
select * from dblink(users_profiles_path, 'select * from follow_users.follow_history') as f(following_id text, followed_id text, follow_time text)
where following_id = $1 and followed_id = $2
) into res;
return res;
end;
$_$;
ALTER FUNCTION public.is_private_user(checkingid text, checkedid text, username text, ip text, port integer, password text) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: comments; Type: TABLE; Schema: bookmarks_list; Owner: postgres
--
CREATE TABLE bookmarks_list.comments (
user_id text NOT NULL,
comment_id text NOT NULL,
sender text NOT NULL,
bookmarked_time text NOT NULL
);
ALTER TABLE bookmarks_list.comments OWNER TO postgres;
--
-- Name: posts; Type: TABLE; Schema: bookmarks_list; Owner: postgres
--
CREATE TABLE bookmarks_list.posts (
user_id text NOT NULL,
post_id text NOT NULL,
sender text NOT NULL,
bookmarked_time text NOT NULL
);
ALTER TABLE bookmarks_list.posts OWNER TO postgres;
--
-- Name: comments_data; Type: TABLE; Schema: comments_list; Owner: postgres
--
CREATE TABLE comments_list.comments_data (
comment_id text NOT NULL,
type text NOT NULL,
content text NOT NULL,
sender text NOT NULL,
upload_time text NOT NULL,
medias_datas text NOT NULL,
parent_post_type text NOT NULL,
parent_post_id text NOT NULL,
parent_post_sender text NOT NULL,
deleted boolean NOT NULL
);
ALTER TABLE comments_list.comments_data OWNER TO postgres;
--
-- Name: comments; Type: TABLE; Schema: likes_list; Owner: postgres
--
CREATE TABLE likes_list.comments (
user_id text NOT NULL,
comment_id text NOT NULL
);
ALTER TABLE likes_list.comments OWNER TO postgres;
--
-- Name: posts; Type: TABLE; Schema: likes_list; Owner: postgres
--
CREATE TABLE likes_list.posts (
user_id text NOT NULL,
post_id text NOT NULL
);
ALTER TABLE likes_list.posts OWNER TO postgres;
--
-- Name: posts_data; Type: TABLE; Schema: posts_list; Owner: postgres
--
CREATE TABLE posts_list.posts_data (
post_id text NOT NULL,
type text NOT NULL,
content text NOT NULL,
sender text NOT NULL,
upload_time text NOT NULL,
medias_datas text NOT NULL,
deleted boolean NOT NULL
);
ALTER TABLE posts_list.posts_data OWNER TO postgres;
--
-- Data for Name: comments; Type: TABLE DATA; Schema: bookmarks_list; Owner: postgres
--
COPY bookmarks_list.comments (user_id, comment_id, sender, bookmarked_time) FROM stdin;
\.
--
-- Data for Name: posts; Type: TABLE DATA; Schema: bookmarks_list; Owner: postgres
--
COPY bookmarks_list.posts (user_id, post_id, sender, bookmarked_time) FROM stdin;
\.
--
-- Data for Name: comments_data; Type: TABLE DATA; Schema: comments_list; Owner: postgres
--
COPY comments_list.comments_data (comment_id, type, content, sender, upload_time, medias_datas, parent_post_type, parent_post_id, parent_post_sender, deleted) FROM stdin;
\.
--
-- Data for Name: comments; Type: TABLE DATA; Schema: likes_list; Owner: postgres
--
COPY likes_list.comments (user_id, comment_id) FROM stdin;
\.
--
-- Data for Name: posts; Type: TABLE DATA; Schema: likes_list; Owner: postgres
--
COPY likes_list.posts (user_id, post_id) FROM stdin;
\.
--
-- Data for Name: posts_data; Type: TABLE DATA; Schema: posts_list; Owner: postgres
--
COPY posts_list.posts_data (post_id, type, content, sender, upload_time, medias_datas, deleted) FROM stdin;
\.
--
-- Name: comments bookmarks_list_comments_constraints; Type: CONSTRAINT; Schema: bookmarks_list; Owner: postgres
--
ALTER TABLE ONLY bookmarks_list.comments
ADD CONSTRAINT bookmarks_list_comments_constraints UNIQUE (user_id, comment_id);
--
-- Name: posts bookmarks_list_posts_constraints; Type: CONSTRAINT; Schema: bookmarks_list; Owner: postgres
--
ALTER TABLE ONLY bookmarks_list.posts
ADD CONSTRAINT bookmarks_list_posts_constraints UNIQUE (user_id, post_id);
--
-- Name: comments_data comments_data_constraints; Type: CONSTRAINT; Schema: comments_list; Owner: postgres
--
ALTER TABLE ONLY comments_list.comments_data
ADD CONSTRAINT comments_data_constraints UNIQUE (comment_id);
--
-- Name: comments likes_list_comments_constraints; Type: CONSTRAINT; Schema: likes_list; Owner: postgres
--
ALTER TABLE ONLY likes_list.comments
ADD CONSTRAINT likes_list_comments_constraints UNIQUE (user_id, comment_id);
--
-- Name: posts likes_list_posts_constraints; Type: CONSTRAINT; Schema: likes_list; Owner: postgres
--
ALTER TABLE ONLY likes_list.posts
ADD CONSTRAINT likes_list_posts_constraints UNIQUE (user_id, post_id);
--
-- Name: posts_data posts_data_pkey; Type: CONSTRAINT; Schema: posts_list; Owner: postgres
--
ALTER TABLE ONLY posts_list.posts_data
ADD CONSTRAINT posts_data_pkey PRIMARY KEY (post_id);
--
-- Name: posts_data posts_list_constraints; Type: CONSTRAINT; Schema: posts_list; Owner: postgres
--
ALTER TABLE ONLY posts_list.posts_data
ADD CONSTRAINT posts_list_constraints UNIQUE (post_id);
--
-- PostgreSQL database dump complete
--