forked from uisky/notabenoid
-
Notifications
You must be signed in to change notification settings - Fork 7
/
init.sql
2629 lines (1816 loc) · 66.6 KB
/
init.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
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: 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 = public, pg_catalog;
--
-- Name: ac (Access Control); Type: DOMAIN; Schema: public; Owner: notabenoid
-- Values:
-- a - all
-- g - group
-- m - moderator
-- o - owner
--
CREATE DOMAIN ac AS character(1)
CONSTRAINT ac_check CHECK (((VALUE)::text = ANY (ARRAY['a'::text, 'g'::text, 'm'::text, 'o'::text])));
ALTER DOMAIN ac OWNER TO notabenoid;
--
-- Name: downloaded_book(integer, inet, inet); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION downloaded_book(_book_id integer, _ip inet, _via inet) RETURNS integer
LANGUAGE plpgsql
AS $$
BEGIN
IF _via IS NULL THEN
IF EXISTS (SELECT 1 FROM download_log WHERE book_id = _book_id AND ip = _ip AND _via IS NULL LIMIT 1) THEN RETURN 0; END IF;
ELSE
IF EXISTS (SELECT 1 FROM download_log WHERE book_id = _book_id AND ip = _ip AND via = _via LIMIT 1) THEN RETURN 0; END IF;
END IF;
INSERT INTO download_log (book_id, ip, via) VALUES (_book_id, _ip, _via);
UPDATE books SET n_dl = n_dl + 1, n_dl_today = n_dl_today + 1 WHERE id = _book_id;
RETURN 1;
END;
$$;
ALTER FUNCTION public.downloaded_book(_book_id integer, _ip inet, _via inet) OWNER TO notabenoid;
--
-- Name: downloaded_book(integer, integer, inet, inet); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION downloaded_book(_book_id integer, _chap_id integer, _ip inet, _via inet) RETURNS integer
LANGUAGE plpgsql
AS $$
BEGIN
IF _via IS NULL THEN
IF EXISTS (SELECT 1 FROM download_log WHERE chap_id = _chap_id AND ip = _ip AND _via IS NULL LIMIT 1) THEN RETURN 0; END IF;
ELSE
IF EXISTS (SELECT 1 FROM download_log WHERE chap_id = _chap_id AND ip = _ip AND via = _via LIMIT 1) THEN RETURN 0; END IF;
END IF;
INSERT INTO download_log (chap_id, ip, via) VALUES (_chap_id, _ip, _via);
UPDATE books SET n_dl = n_dl + 1, n_dl_today = n_dl_today + 1 WHERE id = _book_id;
UPDATE chapters SET n_dl = n_dl + 1, n_dl_today = n_dl_today + 1 WHERE id = _chap_id;
RETURN 1;
END;
$$;
ALTER FUNCTION public.downloaded_book(_book_id integer, _chap_id integer, _ip inet, _via inet) OWNER TO notabenoid;
--
-- Name: group_join(integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION group_join(_user_id integer, _book_id integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF NOT EXISTS(SELECT * FROM groups WHERE user_id = $1 AND book_id = $2) THEN
INSERT INTO groups (user_id, book_id, status) VALUES($1, $2, 1);
ELSE
UPDATE groups SET status = 1 WHERE user_id = $1 AND book_id = $2;
END IF;
RETURN;
END;
$_$;
ALTER FUNCTION public.group_join(_user_id integer, _book_id integer) OWNER TO notabenoid;
--
-- Name: moder_book_cat_put(integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION moder_book_cat_put(_book_id integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF NOT EXISTS(SELECT * FROM moder_book_cat WHERE book_id = $1) THEN
INSERT INTO moder_book_cat (book_id) VALUES($1);
ELSE
UPDATE moder_book_cat SET cdate = now() WHERE book_id = $1;
END IF;
RETURN;
END;
$_$;
ALTER FUNCTION public.moder_book_cat_put(_book_id integer) OWNER TO notabenoid;
--
-- Name: rate_tr(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION rate_tr(_user_id integer, _tr_id integer, _mark integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF NOT EXISTS(SELECT * FROM marks WHERE user_id = $1 AND tr_id = $2) THEN
INSERT INTO marks (user_id, tr_id, mark) VALUES($1, $2, $3);
ELSE
UPDATE marks SET mark = $3 WHERE user_id = $1 AND tr_id = $2;
END IF;
RETURN;
END;
$_$;
ALTER FUNCTION public.rate_tr(_user_id integer, _tr_id integer, _mark integer) OWNER TO notabenoid;
--
-- Name: ready(integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION ready(n_verses integer, d_vars integer) RETURNS double precision
LANGUAGE plpgsql
AS $$
BEGIN
IF n_verses = 0 THEN RETURN 0; ELSE RETURN d_vars::float / n_verses::float; END IF;
END;
$$;
ALTER FUNCTION public.ready(n_verses integer, d_vars integer) OWNER TO notabenoid;
--
-- Name: seen_orig(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION seen_orig(_user_id integer, _orig_id integer, _n_comments integer) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
IF EXISTS(SELECT * FROM seen WHERE user_id = _user_id AND orig_id = _orig_id) THEN UPDATE seen SET seen=now(), n_comments = _n_comments WHERE user_id = _user_id AND orig_id = _orig_id;
ELSE INSERT INTO seen (user_id, orig_id, seen, n_comments, track) VALUES(_user_id, _orig_id, now(), _n_comments, false);
END IF;
RETURN;
END;
$$;
ALTER FUNCTION public.seen_orig(_user_id integer, _orig_id integer, _n_comments integer) OWNER TO notabenoid;
--
-- Name: seen_post(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION seen_post(_user_id integer, _post_id integer, _n_comments integer) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
IF EXISTS(SELECT * FROM seen WHERE user_id = _user_id AND post_id = _post_id) THEN UPDATE seen SET seen=now(), n_comments = _n_comments WHERE user_id = _user_id AND post_id = _post_id;
ELSE INSERT INTO seen (user_id, post_id, seen, n_comments, track) VALUES(_user_id, _post_id, now(), _n_comments, false);
END IF;
RETURN;
END;
$$;
ALTER FUNCTION public.seen_post(_user_id integer, _post_id integer, _n_comments integer) OWNER TO notabenoid;
--
-- Name: track_orig(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION track_orig(_user_id integer, _orig_id integer, _inc integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF EXISTS(SELECT * FROM seen WHERE user_id = $1 AND orig_id = $2) THEN UPDATE seen SET track = true, n_comments = n_comments + _inc WHERE user_id = _user_id AND orig_id = _orig_id;
ELSE INSERT INTO seen (user_id, orig_id, seen, n_comments, track) VALUES(_user_id, _orig_id, NULL, _inc, true);
END IF;
RETURN;
END;
$_$;
ALTER FUNCTION public.track_orig(_user_id integer, _orig_id integer, _inc integer) OWNER TO notabenoid;
--
-- Name: track_post(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: notabenoid
--
CREATE FUNCTION track_post(_user_id integer, _post_id integer, _inc integer) RETURNS void
LANGUAGE plpgsql
AS $_$
BEGIN
IF EXISTS(SELECT * FROM seen WHERE user_id = $1 AND post_id = $2) THEN UPDATE seen SET track = true, n_comments = n_comments + _inc WHERE user_id = _user_id AND post_id = _post_id;
ELSE INSERT INTO seen (user_id, post_id, seen, n_comments, track) VALUES(_user_id, _post_id, NULL, _inc, true);
END IF;
RETURN;
END;
$_$;
ALTER FUNCTION public.track_post(_user_id integer, _post_id integer, _inc integer) OWNER TO notabenoid;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: ban; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE ban (
user_id integer NOT NULL,
until date DEFAULT '2031-08-08'::date NOT NULL
);
ALTER TABLE ban OWNER TO notabenoid;
--
-- Name: blog_posts; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE blog_posts (
id integer NOT NULL,
user_id integer NOT NULL,
book_id integer,
cdate timestamp with time zone DEFAULT now() NOT NULL,
n_comments integer DEFAULT 0 NOT NULL,
lastcomment timestamp with time zone DEFAULT now(),
topics smallint NOT NULL,
title character varying(256),
body text NOT NULL
);
ALTER TABLE blog_posts OWNER TO notabenoid;
--
-- Name: blog_posts_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE blog_posts_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE blog_posts_id_seq OWNER TO notabenoid;
--
-- Name: blog_posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE blog_posts_id_seq OWNED BY blog_posts.id;
--
-- Name: book_ban_reasons; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE book_ban_reasons (
book_id integer NOT NULL,
cdate timestamp without time zone DEFAULT now() NOT NULL,
title character varying(255),
url character varying(255),
email character varying(255),
message text
);
ALTER TABLE book_ban_reasons OWNER TO notabenoid;
--
-- Name: book_cat_export; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE book_cat_export (
book_id integer,
cat_id integer
);
ALTER TABLE book_cat_export OWNER TO notabenoid;
--
-- Name: book_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE book_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE book_id_seq OWNER TO notabenoid;
--
-- Name: bookmarks; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE bookmarks (
id integer NOT NULL,
user_id integer NOT NULL,
book_id integer NOT NULL,
orig_id integer,
ord smallint,
note character varying(255),
cdate timestamp with time zone DEFAULT now() NOT NULL,
watch boolean DEFAULT false NOT NULL
);
ALTER TABLE bookmarks OWNER TO notabenoid;
--
-- Name: bookmarks_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE bookmarks_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE bookmarks_id_seq OWNER TO notabenoid;
--
-- Name: bookmarks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE bookmarks_id_seq OWNED BY bookmarks.id;
--
-- Name: books; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE books (
id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
owner_id integer NOT NULL,
typ character(1) DEFAULT 'A'::bpchar NOT NULL,
opts bit(8) DEFAULT (0)::bit(8) NOT NULL,
cat_id integer,
topics bit(32) DEFAULT (0)::bit(32) NOT NULL,
s_lang smallint NOT NULL,
t_lang smallint NOT NULL,
s_title character varying(255) NOT NULL,
t_title character varying(255) NOT NULL,
descr text,
img smallint[] NOT NULL,
n_chapters integer DEFAULT 0 NOT NULL,
n_verses integer DEFAULT 0 NOT NULL,
n_vars integer DEFAULT 0 NOT NULL,
d_vars integer DEFAULT 0 NOT NULL,
n_invites smallint DEFAULT 30 NOT NULL,
n_dl integer DEFAULT 0 NOT NULL,
n_dl_today integer DEFAULT 0 NOT NULL,
last_tr timestamp with time zone,
facecontrol smallint DEFAULT 0 NOT NULL,
ac_read ac DEFAULT 'a'::bpchar NOT NULL,
ac_trread ac DEFAULT 'a'::bpchar NOT NULL,
ac_gen ac DEFAULT 'a'::bpchar NOT NULL,
ac_rate ac DEFAULT 'a'::bpchar NOT NULL,
ac_comment ac DEFAULT 'a'::bpchar NOT NULL,
ac_tr ac DEFAULT 'g'::bpchar NOT NULL,
ac_blog_r ac DEFAULT 'a'::bpchar NOT NULL,
ac_blog_c ac DEFAULT 'a'::bpchar NOT NULL,
ac_blog_w ac DEFAULT 'g'::bpchar NOT NULL,
ac_chap_edit ac DEFAULT 'm'::bpchar NOT NULL,
ac_book_edit ac DEFAULT 'o'::bpchar NOT NULL,
ac_membership ac DEFAULT 'm'::bpchar NOT NULL,
ac_announce ac DEFAULT 'm'::bpchar NOT NULL,
CONSTRAINT books_ac_announce_check CHECK (((ac_announce)::bpchar = ANY (ARRAY['g'::bpchar, 'm'::bpchar, 'o'::bpchar]))),
CONSTRAINT books_ac_book_edit_check CHECK (((ac_book_edit)::bpchar = ANY (ARRAY['m'::bpchar, 'o'::bpchar]))),
CONSTRAINT books_ac_chap_edit_check CHECK (((ac_chap_edit)::bpchar = ANY (ARRAY['m'::bpchar, 'o'::bpchar]))),
CONSTRAINT books_ac_membership_check CHECK (((ac_membership)::bpchar = ANY (ARRAY['m'::bpchar, 'o'::bpchar])))
);
ALTER TABLE books OWNER TO notabenoid;
--
-- Name: books_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE books_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE books_id_seq OWNER TO notabenoid;
--
-- Name: books_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE books_id_seq OWNED BY books.id;
--
-- Name: catalog; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE catalog (
id integer NOT NULL,
pid integer,
mp smallint[] NOT NULL,
title text,
available boolean DEFAULT true NOT NULL
);
ALTER TABLE catalog OWNER TO notabenoid;
--
-- Name: catalog_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE catalog_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE catalog_id_seq OWNER TO notabenoid;
--
-- Name: catalog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE catalog_id_seq OWNED BY catalog.id;
--
-- Name: chapters; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE chapters (
id integer NOT NULL,
book_id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
last_tr timestamp with time zone,
n_verses integer DEFAULT 0 NOT NULL,
n_vars integer DEFAULT 0 NOT NULL,
d_vars integer DEFAULT 0 NOT NULL,
n_dl integer DEFAULT 0 NOT NULL,
n_dl_today integer DEFAULT 0 NOT NULL,
ord integer NOT NULL,
status smallint NOT NULL,
title character varying(300) NOT NULL,
ac_read ac,
ac_trread ac,
ac_gen ac,
ac_rate ac,
ac_comment ac,
ac_tr ac
);
ALTER TABLE chapters OWNER TO notabenoid;
--
-- Name: chapters_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE chapters_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE chapters_id_seq OWNER TO notabenoid;
--
-- Name: chapters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE chapters_id_seq OWNED BY chapters.id;
--
-- Name: comments; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE comments (
id integer NOT NULL,
post_id integer,
orig_id integer,
pid integer,
mp smallint[] NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
ip inet,
user_id integer,
body text NOT NULL,
rating smallint DEFAULT 0 NOT NULL,
n_votes smallint DEFAULT 0 NOT NULL
);
ALTER TABLE comments OWNER TO notabenoid;
--
-- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE comments_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE comments_id_seq OWNER TO notabenoid;
--
-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE comments_id_seq OWNED BY comments.id;
--
-- Name: comments_rating; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE comments_rating (
cdate timestamp with time zone DEFAULT now() NOT NULL,
comment_id integer NOT NULL,
user_id integer NOT NULL,
mark smallint DEFAULT 0 NOT NULL
);
ALTER TABLE comments_rating OWNER TO notabenoid;
--
-- Name: dict; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE dict (
id integer NOT NULL,
book_id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
user_id integer NOT NULL,
term character varying(255) NOT NULL,
descr character varying(255) NOT NULL
);
ALTER TABLE dict OWNER TO notabenoid;
--
-- Name: dict_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE dict_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE dict_id_seq OWNER TO notabenoid;
--
-- Name: dict_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE dict_id_seq OWNED BY dict.id;
--
-- Name: dima360; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE dima360 (
id integer,
login text
);
ALTER TABLE dima360 OWNER TO notabenoid;
--
-- Name: download_log; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE download_log (
chap_id integer NOT NULL,
ip inet NOT NULL,
via inet
);
ALTER TABLE download_log OWNER TO notabenoid;
--
-- Name: group_queue; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE group_queue (
book_id integer NOT NULL,
user_id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
message text
);
ALTER TABLE group_queue OWNER TO notabenoid;
--
-- Name: groups; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE groups (
book_id integer NOT NULL,
user_id integer NOT NULL,
status smallint DEFAULT 0 NOT NULL,
since timestamp with time zone DEFAULT now() NOT NULL,
last_tr timestamp with time zone,
n_trs integer DEFAULT 0 NOT NULL,
rating integer DEFAULT 0 NOT NULL
);
ALTER TABLE groups OWNER TO notabenoid;
--
-- Name: invites; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE invites (
cdate timestamp with time zone DEFAULT now() NOT NULL,
from_uid integer NOT NULL,
to_uid integer NOT NULL,
book_id integer NOT NULL
);
ALTER TABLE invites OWNER TO notabenoid;
--
-- Name: karma_rates; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE karma_rates (
dat timestamp with time zone DEFAULT now() NOT NULL,
from_uid integer NOT NULL,
to_uid integer NOT NULL,
mark smallint NOT NULL,
note character varying(255) DEFAULT ''::character varying NOT NULL,
CONSTRAINT karma_rates_mark_check CHECK ((abs(mark) = 1))
);
ALTER TABLE karma_rates OWNER TO notabenoid;
--
-- Name: languages; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE languages (
id smallint NOT NULL,
typ smallint NOT NULL,
title character varying(100),
title_r character varying(100)
);
ALTER TABLE languages OWNER TO notabenoid;
--
-- Name: languages_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE languages_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE languages_id_seq OWNER TO notabenoid;
--
-- Name: languages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE languages_id_seq OWNED BY languages.id;
--
-- Name: mail_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE mail_id_seq
START WITH 533179
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE mail_id_seq OWNER TO notabenoid;
--
-- Name: mail; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE mail (
id integer DEFAULT nextval('mail_id_seq'::regclass) NOT NULL,
user_id integer NOT NULL,
buddy_id integer,
folder smallint NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
subj character varying(255) NOT NULL,
body text NOT NULL,
seen boolean
);
ALTER TABLE mail OWNER TO notabenoid;
--
-- Name: marks; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE marks (
user_id integer NOT NULL,
tr_id integer NOT NULL,
mark smallint NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE marks OWNER TO notabenoid;
--
-- Name: moder_book_cat; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE moder_book_cat (
book_id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE moder_book_cat OWNER TO notabenoid;
--
-- Name: moving; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE moving (
ip inet NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
x smallint NOT NULL,
y smallint NOT NULL,
color smallint[] NOT NULL,
t character varying(120) NOT NULL
);
ALTER TABLE moving OWNER TO notabenoid;
--
-- Name: notices; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE notices (
id integer NOT NULL,
user_id integer NOT NULL,
cdate timestamp with time zone DEFAULT now() NOT NULL,
seen boolean DEFAULT false NOT NULL,
typ smallint,
msg text DEFAULT ''::text NOT NULL
);
ALTER TABLE notices OWNER TO notabenoid;
--
-- Name: notices_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE notices_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE notices_id_seq OWNER TO notabenoid;
--
-- Name: notices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE notices_id_seq OWNED BY notices.id;
--
-- Name: orig; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE orig (
id integer NOT NULL,
chap_id integer NOT NULL,
ord integer,
t1 time(3) without time zone,
t2 time(3) without time zone,
body text DEFAULT ''::text NOT NULL,
n_comments smallint DEFAULT 0 NOT NULL,
n_trs smallint DEFAULT 0 NOT NULL
);
ALTER TABLE orig OWNER TO notabenoid;
--
-- Name: orig_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE orig_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE orig_id_seq OWNER TO notabenoid;
--
-- Name: orig_id_seq1; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE orig_id_seq1
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE orig_id_seq1 OWNER TO notabenoid;
--
-- Name: orig_id_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid
--
ALTER SEQUENCE orig_id_seq1 OWNED BY orig.id;
--
-- Name: orig_old_id; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE orig_old_id (
id integer NOT NULL,
chap_id integer NOT NULL,
old_id integer NOT NULL
);
ALTER TABLE orig_old_id OWNER TO notabenoid;
--
-- Name: poll_answers; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE poll_answers (
poll_id smallint NOT NULL,
q_id smallint NOT NULL,
user_id integer,
cdate timestamp without time zone DEFAULT now() NOT NULL,
ip inet NOT NULL,
answer text DEFAULT ''::text NOT NULL
);
ALTER TABLE poll_answers OWNER TO notabenoid;
--
-- Name: poll_tmp; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE poll_tmp (
poll_id smallint NOT NULL,
q_id smallint NOT NULL,
user_id integer,
cdate timestamp without time zone NOT NULL,
ip inet NOT NULL,
answer text NOT NULL
);
ALTER TABLE poll_tmp OWNER TO notabenoid;
--
-- Name: recalc_log; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE recalc_log (
book_id integer NOT NULL,
user_id integer NOT NULL,
dat timestamp with time zone DEFAULT now() NOT NULL
);
ALTER TABLE recalc_log OWNER TO notabenoid;
--
-- Name: reg_invites; Type: TABLE; Schema: public; Owner: notabenoid; Tablespace:
--
CREATE TABLE reg_invites (
id integer NOT NULL,
from_id integer NOT NULL,
to_id integer,
to_email character varying(256),
cdate timestamp without time zone DEFAULT now() NOT NULL,
message text,
code character varying(80)
);
ALTER TABLE reg_invites OWNER TO notabenoid;
--
-- Name: reg_invites_id_seq; Type: SEQUENCE; Schema: public; Owner: notabenoid
--
CREATE SEQUENCE reg_invites_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE reg_invites_id_seq OWNER TO notabenoid;
--
-- Name: reg_invites_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: notabenoid