-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathschema.sql
More file actions
2715 lines (1777 loc) · 65.5 KB
/
schema.sql
File metadata and controls
2715 lines (1777 loc) · 65.5 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
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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: posts; Type: SCHEMA; Schema: -; Owner: point
--
CREATE SCHEMA posts;
ALTER SCHEMA posts OWNER TO point;
--
-- Name: subs; Type: SCHEMA; Schema: -; Owner: point
--
CREATE SCHEMA subs;
ALTER SCHEMA subs OWNER TO point;
--
-- Name: users; Type: SCHEMA; Schema: -; Owner: point
--
CREATE SCHEMA users;
ALTER SCHEMA users OWNER TO point;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = posts, pg_catalog;
--
-- Name: post_type; Type: TYPE; Schema: posts; Owner: point
--
CREATE TYPE post_type AS ENUM (
'post',
'feed'
);
ALTER TYPE posts.post_type OWNER TO point;
SET search_path = users, pg_catalog;
--
-- Name: account_type; Type: TYPE; Schema: users; Owner: point
--
CREATE TYPE account_type AS ENUM (
'xmpp',
'icq',
'email'
);
ALTER TYPE users.account_type OWNER TO point;
--
-- Name: user_type; Type: TYPE; Schema: users; Owner: point
--
CREATE TYPE user_type AS ENUM (
'user',
'group',
'feed'
);
ALTER TYPE users.user_type OWNER TO point;
SET search_path = posts, pg_catalog;
--
-- Name: delete_recommendation_recent(); Type: FUNCTION; Schema: posts; Owner: point
--
CREATE FUNCTION delete_recommendation_recent() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
DELETE FROM "posts"."recent"
WHERE user_id=OLD.user_id AND post_id=OLD.post_id
AND comment_id=OLD.comment_id;
DELETE FROM "posts"."recent_blog"
WHERE user_id=OLD.user_id AND post_id=OLD.post_id
AND comment_id=OLD.comment_id;
RETURN OLD;
END;
$$;
ALTER FUNCTION posts.delete_recommendation_recent() OWNER TO point;
--
-- Name: insert_post_by_type(); Type: FUNCTION; Schema: posts; Owner: point
--
CREATE FUNCTION insert_post_by_type() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF new."type" = 'feed' THEN
INSERT INTO "posts"."feeds" VALUES (new.*);
ELSE
INSERT INTO "posts"."posts" VALUES (new.*);
END IF;
RETURN null;
END;
$$;
ALTER FUNCTION posts.insert_post_by_type() OWNER TO point;
--
-- Name: insert_post_recent(); Type: FUNCTION; Schema: posts; Owner: point
--
CREATE FUNCTION insert_post_recent() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
u record;
BEGIN
IF NEW.private THEN
RETURN NEW;
END IF;
FOR u IN
SELECT user_id FROM subs.users WHERE to_user_id = NEW.author
UNION
SELECT user_id FROM subs.tags_global WHERE tag = ANY(NEW.tags)
UNION
SELECT user_id FROM subs.tags_user WHERE to_user_id = NEW.author
AND LOWER(tag) = ANY(public.array_lowercase(NEW.tags))
EXCEPT
SELECT user_id FROM posts.tags_blacklist_global WHERE
LOWER(tag) = ANY(public.array_lowercase(NEW.tags))
EXCEPT
SELECT user_id FROM posts.tags_blacklist_user WHERE to_user_id = NEW.author
AND LOWER(tag) = ANY(public.array_lowercase(NEW.tags))
EXCEPT
SELECT user_id FROM users.blacklist WHERE to_user_id = NEW.author
LOOP
INSERT INTO posts.recent (rcpt_id, user_id, post_id, created)
VALUES (u.user_id, NEW.author, NEW.id, NEW.created);
END LOOP;
INSERT INTO posts.recent_blog (user_id, post_id, created)
VALUES (NEW.author, NEW.id, NEW.created);
RETURN NEW;
END;
$$;
ALTER FUNCTION posts.insert_post_recent() OWNER TO point;
--
-- Name: insert_recommendation_recent(); Type: FUNCTION; Schema: posts; Owner: point
--
CREATE FUNCTION insert_recommendation_recent() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
post_author bigint;
post_tags text[];
comment_author bigint;
u record;
priv boolean;
BEGIN
SELECT author, tags INTO post_author, post_tags FROM posts.posts WHERE id = NEW.post_id;
IF NEW.comment_id IS NOT NULL AND NEW.comment_id > 0 THEN
SELECT author INTO comment_author FROM posts.comments
WHERE post_id = NEW.post_id AND comment_id = NEW.comment_id;
ELSE
comment_author := 0;
END IF;
SELECT private INTO priv FROM users.profile WHERE id=post_author;
IF priv THEN
FOR u IN
((SELECT user_id FROM subs.users WHERE to_user_id = NEW.user_id
AND user_id != post_author
AND user_id != comment_author
EXCEPT
SELECT user_id FROM users.blacklist
WHERE to_user_id IN (post_author, comment_author))
EXCEPT
SELECT user_id FROM posts.recommendations_recv
WHERE post_id = NEW.post_id AND comment_id = NEW.comment_id)
EXCEPT
SELECT user_id FROM posts.tags_blacklist_user
WHERE to_user_id=post_author AND tag=ANY(post_tags)
EXCEPT
SELECT user_id FROM posts.tags_blacklist_global
WHERE tag=ANY(post_tags)
INTERSECT
SELECT to_user_id FROM users.whitelist WHERE user_id=post_author
LOOP
INSERT INTO posts.recent (rcpt_id, user_id, is_rec, post_id, comment_id, created, rcid)
VALUES (u.user_id, NEW.user_id, true, NEW.post_id, NEW.comment_id, NEW.created, NEW.rcid);
END LOOP;
ELSE
FOR u IN
(SELECT user_id FROM subs.users WHERE to_user_id = NEW.user_id
AND user_id != post_author
AND user_id != comment_author
EXCEPT
SELECT user_id FROM posts.tags_blacklist_user
WHERE to_user_id=post_author AND tag=ANY(post_tags)
EXCEPT
SELECT user_id FROM posts.tags_blacklist_global
WHERE tag=ANY(post_tags)
EXCEPT
SELECT user_id FROM users.blacklist
WHERE to_user_id IN (post_author, comment_author))
EXCEPT
SELECT user_id FROM posts.recommendations_recv
WHERE post_id = NEW.post_id AND comment_id = NEW.comment_id
LOOP
INSERT INTO posts.recent (rcpt_id, user_id, is_rec, post_id, comment_id, created, rcid)
VALUES (u.user_id, NEW.user_id, true, NEW.post_id, NEW.comment_id, NEW.created, NEW.rcid);
END LOOP;
END IF;
INSERT INTO posts.recent_blog
(user_id, is_rec, post_id, comment_id, created, rcid)
VALUES (NEW.user_id, true, NEW.post_id, NEW.comment_id, NEW.created, NEW.rcid);
RETURN NEW;
END;
$$;
ALTER FUNCTION posts.insert_recommendation_recent() OWNER TO point;
--
-- Name: insert_tags_blacklist(); Type: FUNCTION; Schema: posts; Owner: point
--
CREATE FUNCTION insert_tags_blacklist() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF new.to_user_id IS NULL THEN
INSERT INTO "posts"."tags_blacklist_global"
VALUES (new.user_id, null, new.tag);
ELSE
INSERT INTO "posts"."tags_blacklist_user"
VALUES (new.user_id, new.to_user_id, new.tag);
END IF;
RETURN null;
END;
$$;
ALTER FUNCTION posts.insert_tags_blacklist() OWNER TO point;
SET search_path = public, pg_catalog;
--
-- Name: array_lowercase(character varying[]); Type: FUNCTION; Schema: public; Owner: point
--
CREATE FUNCTION array_lowercase(character varying[]) RETURNS character varying[]
LANGUAGE sql IMMUTABLE
AS $_$
SELECT array_agg(q.tag) FROM (
SELECT btrim(lower(unnest($1)))::varchar AS tag
) AS q;
$_$;
ALTER FUNCTION public.array_lowercase(character varying[]) OWNER TO point;
--
-- Name: comment_delete(); Type: FUNCTION; Schema: public; Owner: point
--
CREATE FUNCTION comment_delete() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
DELETE FROM posts.recommendations
WHERE post_id=OLD.post_id AND comment_id=OLD.comment_id;
RETURN OLD;
END;
$$;
ALTER FUNCTION public.comment_delete() OWNER TO point;
SET search_path = subs, pg_catalog;
--
-- Name: insert_tags(); Type: FUNCTION; Schema: subs; Owner: point
--
CREATE FUNCTION insert_tags() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF new.to_user_id IS NULL THEN
INSERT INTO "subs"."tags_global"
VALUES (new.user_id, null, new.tag);
ELSE
INSERT INTO "subs"."tags_user"
VALUES (new.user_id, new.to_user_id, new.tag);
END IF;
RETURN null;
END;
$$;
ALTER FUNCTION subs.insert_tags() OWNER TO point;
SET search_path = posts, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: bookmarks; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE bookmarks (
user_id integer NOT NULL,
post_id bigint NOT NULL,
comment_id integer DEFAULT 0 NOT NULL,
created timestamp with time zone DEFAULT now(),
btext text
);
ALTER TABLE posts.bookmarks OWNER TO point;
--
-- Name: comments; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE comments (
id bigint NOT NULL,
post_id bigint NOT NULL,
comment_id integer NOT NULL,
author bigint NOT NULL,
to_user_id integer,
to_comment_id integer,
created timestamp with time zone DEFAULT now(),
text text NOT NULL,
anon_login text,
files text[]
);
ALTER TABLE posts.comments OWNER TO point;
--
-- Name: comments_id_seq; Type: SEQUENCE; Schema: posts; Owner: point
--
CREATE SEQUENCE comments_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE posts.comments_id_seq OWNER TO point;
--
-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: posts; Owner: point
--
ALTER SEQUENCE comments_id_seq OWNED BY comments.id;
--
-- Name: posts; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE posts (
id bigint NOT NULL,
author bigint NOT NULL,
type post_type DEFAULT 'post'::post_type NOT NULL,
private boolean DEFAULT false,
created timestamp with time zone DEFAULT now(),
resource text,
tags text[],
text text NOT NULL,
rpost bigint,
rcomment integer,
rcreated timestamp without time zone,
rtext text,
edited boolean DEFAULT false,
title text,
link text,
archive boolean DEFAULT false,
files text[]
);
ALTER TABLE posts.posts OWNER TO point;
--
-- Name: posts_id_seq; Type: SEQUENCE; Schema: posts; Owner: point
--
CREATE SEQUENCE posts_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE posts.posts_id_seq OWNER TO point;
--
-- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: posts; Owner: point
--
ALTER SEQUENCE posts_id_seq OWNED BY posts.id;
--
-- Name: recent; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE recent (
id bigint NOT NULL,
rcpt_id bigint NOT NULL,
user_id bigint NOT NULL,
is_rec boolean DEFAULT false,
post_id bigint,
comment_id integer DEFAULT 0 NOT NULL,
created timestamp with time zone DEFAULT now(),
rcid bigint
);
ALTER TABLE posts.recent OWNER TO point;
--
-- Name: recent_blog; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE recent_blog (
id bigint NOT NULL,
user_id bigint NOT NULL,
is_rec boolean DEFAULT false,
post_id bigint,
comment_id integer DEFAULT 0 NOT NULL,
created timestamp with time zone DEFAULT now(),
rcid bigint
);
ALTER TABLE posts.recent_blog OWNER TO point;
--
-- Name: recent_blog_id_seq; Type: SEQUENCE; Schema: posts; Owner: point
--
CREATE SEQUENCE recent_blog_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE posts.recent_blog_id_seq OWNER TO point;
--
-- Name: recent_blog_id_seq; Type: SEQUENCE OWNED BY; Schema: posts; Owner: point
--
ALTER SEQUENCE recent_blog_id_seq OWNED BY recent_blog.id;
--
-- Name: recent_id_seq; Type: SEQUENCE; Schema: posts; Owner: point
--
CREATE SEQUENCE recent_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE posts.recent_id_seq OWNER TO point;
--
-- Name: recent_id_seq; Type: SEQUENCE OWNED BY; Schema: posts; Owner: point
--
ALTER SEQUENCE recent_id_seq OWNED BY recent.id;
--
-- Name: recipients; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE recipients (
post_id bigint NOT NULL,
user_id integer NOT NULL
);
ALTER TABLE posts.recipients OWNER TO point;
--
-- Name: recommendations; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE recommendations (
post_id bigint NOT NULL,
comment_id bigint NOT NULL,
user_id integer NOT NULL,
text text,
rcid bigint,
created timestamp with time zone DEFAULT now()
);
ALTER TABLE posts.recommendations OWNER TO point;
--
-- Name: recommendations_recv; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE recommendations_recv (
post_id bigint NOT NULL,
comment_id bigint NOT NULL,
user_id integer NOT NULL,
text text
);
ALTER TABLE posts.recommendations_recv OWNER TO point;
--
-- Name: tags; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE tags (
post_id bigint NOT NULL,
user_id integer NOT NULL,
tag text NOT NULL
);
ALTER TABLE posts.tags OWNER TO point;
--
-- Name: tags_blacklist; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE tags_blacklist (
user_id bigint NOT NULL,
to_user_id bigint,
tag text NOT NULL
);
ALTER TABLE posts.tags_blacklist OWNER TO point;
--
-- Name: tags_blacklist_global; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE tags_blacklist_global (
CONSTRAINT tags_blacklist_global_to_user_id_check CHECK ((to_user_id IS NULL))
)
INHERITS (tags_blacklist);
ALTER TABLE posts.tags_blacklist_global OWNER TO point;
--
-- Name: tags_blacklist_user; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE tags_blacklist_user (
CONSTRAINT tags_blacklist_user_to_user_id_check CHECK ((to_user_id IS NOT NULL))
)
INHERITS (tags_blacklist);
ALTER TABLE ONLY tags_blacklist_user ALTER COLUMN to_user_id SET NOT NULL;
ALTER TABLE posts.tags_blacklist_user OWNER TO point;
--
-- Name: unread_comments; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE unread_comments (
user_id integer NOT NULL,
post_id bigint NOT NULL,
comment_id integer NOT NULL,
type text DEFAULT 'post'::text,
created timestamp with time zone DEFAULT now()
);
ALTER TABLE posts.unread_comments OWNER TO point;
--
-- Name: unread_posts; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE unread_posts (
user_id integer NOT NULL,
post_id bigint NOT NULL,
type text DEFAULT 'post'::text
);
ALTER TABLE posts.unread_posts OWNER TO point;
--
-- Name: updates; Type: TABLE; Schema: posts; Owner: point; Tablespace:
--
CREATE TABLE updates (
post_id bigint NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
text text NOT NULL
);
ALTER TABLE posts.updates OWNER TO point;
SET search_path = public, pg_catalog;
--
-- Name: test; Type: TABLE; Schema: public; Owner: point; Tablespace:
--
CREATE TABLE test (
ts timestamp without time zone
);
ALTER TABLE public.test OWNER TO point;
SET search_path = subs, pg_catalog;
--
-- Name: posts; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE posts (
user_id bigint NOT NULL,
post_id bigint NOT NULL
);
ALTER TABLE subs.posts OWNER TO point;
--
-- Name: recommendations; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE recommendations (
user_id integer NOT NULL,
to_user_id integer NOT NULL
);
ALTER TABLE subs.recommendations OWNER TO point;
--
-- Name: requests; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE requests (
user_id integer NOT NULL,
to_user_id integer NOT NULL
);
ALTER TABLE subs.requests OWNER TO point;
--
-- Name: tags; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE tags (
user_id bigint NOT NULL,
to_user_id bigint,
tag text NOT NULL
);
ALTER TABLE subs.tags OWNER TO point;
--
-- Name: tags_global; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE tags_global (
CONSTRAINT tags_global_to_user_id_check CHECK ((to_user_id IS NULL))
)
INHERITS (tags);
ALTER TABLE subs.tags_global OWNER TO point;
--
-- Name: tags_user; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE tags_user (
CONSTRAINT tags_user_to_user_id_check CHECK ((to_user_id IS NOT NULL))
)
INHERITS (tags);
ALTER TABLE ONLY tags_user ALTER COLUMN to_user_id SET NOT NULL;
ALTER TABLE subs.tags_user OWNER TO point;
--
-- Name: users; Type: TABLE; Schema: subs; Owner: point; Tablespace:
--
CREATE TABLE users (
user_id integer NOT NULL,
to_user_id integer NOT NULL
);
ALTER TABLE subs.users OWNER TO point;
SET search_path = users, pg_catalog;
--
-- Name: accounts; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE accounts (
id integer NOT NULL,
user_id integer,
type account_type NOT NULL,
address text
);
ALTER TABLE users.accounts OWNER TO point;
--
-- Name: accounts_id_seq; Type: SEQUENCE; Schema: users; Owner: point
--
CREATE SEQUENCE accounts_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE users.accounts_id_seq OWNER TO point;
--
-- Name: accounts_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: point
--
ALTER SEQUENCE accounts_id_seq OWNED BY accounts.id;
--
-- Name: accounts_unconfirmed; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE accounts_unconfirmed (
id integer NOT NULL,
user_id integer,
type account_type NOT NULL,
address text NOT NULL,
code character(40) NOT NULL
);
ALTER TABLE users.accounts_unconfirmed OWNER TO point;
--
-- Name: accounts_unconfirmed_id_seq; Type: SEQUENCE; Schema: users; Owner: point
--
CREATE SEQUENCE accounts_unconfirmed_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE users.accounts_unconfirmed_id_seq OWNER TO point;
--
-- Name: accounts_unconfirmed_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: point
--
ALTER SEQUENCE accounts_unconfirmed_id_seq OWNED BY accounts_unconfirmed.id;
--
-- Name: aliases; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE aliases (
alias character varying(255) NOT NULL,
command text NOT NULL
);
ALTER TABLE users.aliases OWNER TO point;
--
-- Name: blacklist; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE blacklist (
user_id integer NOT NULL,
to_user_id integer NOT NULL
);
ALTER TABLE users.blacklist OWNER TO point;
--
-- Name: domains; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE domains (
id integer NOT NULL,
domain text NOT NULL
);
ALTER TABLE users.domains OWNER TO point;
--
-- Name: feeds; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE feeds (
id bigint NOT NULL,
url text NOT NULL
);
ALTER TABLE users.feeds OWNER TO point;
--
-- Name: info; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE info (
id bigint NOT NULL,
name text,
created timestamp with time zone DEFAULT now(),
gender boolean,
avatar text,
email text,
xmpp text,
icq text,
skype text,
about text DEFAULT ''::text,
birthdate date,
location text,
homepage text
);
ALTER TABLE users.info OWNER TO point;
--
-- Name: logins; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE logins (
id integer NOT NULL,
login character varying(32) NOT NULL,
password character(40),
type user_type DEFAULT 'user'::user_type
);
ALTER TABLE users.logins OWNER TO point;
--
-- Name: logins_id_seq; Type: SEQUENCE; Schema: users; Owner: point
--
CREATE SEQUENCE logins_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE users.logins_id_seq OWNER TO point;
--
-- Name: logins_id_seq; Type: SEQUENCE OWNED BY; Schema: users; Owner: point
--
ALTER SEQUENCE logins_id_seq OWNED BY logins.id;
--
-- Name: profile; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE profile (
id bigint NOT NULL,
private boolean DEFAULT false,
lang character(2) DEFAULT 'en'::bpchar,
tz character varying DEFAULT 'Europe/Moscow'::character varying NOT NULL,
deny_anonymous boolean DEFAULT false
);
ALTER TABLE users.profile OWNER TO point;
--
-- Name: profile_im; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE profile_im (
id bigint NOT NULL,
off boolean DEFAULT false,
xhtml boolean DEFAULT false,
highlight boolean DEFAULT false,
user_resource boolean DEFAULT false,
post_resource boolean DEFAULT false,
cut integer,
auto_switch boolean DEFAULT true
);
ALTER TABLE users.profile_im OWNER TO point;
--
-- Name: profile_www; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE profile_www (
id bigint NOT NULL,
blog_css text,
global_css text,
blogcss text,
usercss text,
ignorecss boolean DEFAULT false,
tree boolean DEFAULT false
);
ALTER TABLE users.profile_www OWNER TO point;
--
-- Name: ulogin_accounts; Type: TABLE; Schema: users; Owner: point; Tablespace:
--
CREATE TABLE ulogin_accounts (
id bigint NOT NULL,
network text NOT NULL,
uid text NOT NULL,
nickname text,