997dfcd39db5dcb57a54f175d7f131308fa88b4a
[mir.git] / dbscripts / create_pg.sql
1 --
2 -- Selected TOC Entries:
3 --
4 \connect - postgres
5 --
6 -- TOC Entry ID 2 (OID 19796)
7 --
8 -- Name: media_id_seq Type: SEQUENCE Owner: postgres
9 --
10
11 CREATE SEQUENCE "media_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
12
13 --
14 -- TOC Entry ID 3 (OID 19815)
15 --
16 -- Name: media_folder_id_seq Type: SEQUENCE Owner: postgres
17 --
18
19 CREATE SEQUENCE "media_folder_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
20
21 --
22 -- TOC Entry ID 4 (OID 19834)
23 --
24 -- Name: feature_id_seq Type: SEQUENCE Owner: postgres
25 --
26
27 CREATE SEQUENCE "feature_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
28
29 --
30 -- TOC Entry ID 5 (OID 19853)
31 --
32 -- Name: topic_id_seq Type: SEQUENCE Owner: postgres
33 --
34
35 CREATE SEQUENCE "topic_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
36
37 --
38 -- TOC Entry ID 6 (OID 19872)
39 --
40 -- Name: webdb_users_id_seq Type: SEQUENCE Owner: postgres
41 --
42
43 CREATE SEQUENCE "webdb_users_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
44
45 --
46 -- TOC Entry ID 7 (OID 19891)
47 --
48 -- Name: comment_id_seq Type: SEQUENCE Owner: postgres
49 --
50
51 CREATE SEQUENCE "comment_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
52
53 --
54 -- TOC Entry ID 8 (OID 19910)
55 --
56 -- Name: breaking_id_seq Type: SEQUENCE Owner: postgres
57 --
58
59 CREATE SEQUENCE "breaking_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
60
61 --
62 -- TOC Entry ID 9 (OID 19929)
63 --
64 -- Name: messages_id_seq Type: SEQUENCE Owner: postgres
65 --
66
67 CREATE SEQUENCE "messages_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
68
69 --
70 -- TOC Entry ID 10 (OID 19948)
71 --
72 -- Name: media_type_id_seq Type: SEQUENCE Owner: postgres
73 --
74
75 CREATE SEQUENCE "media_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
76
77 --
78 -- TOC Entry ID 12 (OID 19967)
79 --
80 -- Name: media_folder Type: TABLE Owner: postgres
81 --
82
83 CREATE TABLE "media_folder" (
84         "id" integer DEFAULT nextval('media_folder_id_seq'::text) NOT NULL,
85         "name" character varying(255) NOT NULL,
86         "date" character(8) NOT NULL,
87         "place" character varying(80),
88         "keywords" text,
89         "comment" text,
90         "webdb_create" timestamp with time zone NOT NULL,
91         "webdb_lastchange" timestamp with time zone
92 );
93
94 --
95 -- TOC Entry ID 13 (OID 20000)
96 --
97 -- Name: media_type Type: TABLE Owner: postgres
98 --
99
100 CREATE TABLE "media_type" (
101         "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL,
102         "name" character varying(80) NOT NULL,
103         "mime_type" character varying(40) NOT NULL,
104         "classname" character varying(80) NOT NULL,
105         "tablename" character varying(80) NOT NULL,
106         "dcname" character varying(20)
107 );
108
109 --
110 -- TOC Entry ID 14 (OID 20016)
111 --
112 -- Name: img_format Type: TABLE Owner: postgres
113 --
114
115 CREATE TABLE "img_format" (
116         "id" smallint NOT NULL,
117         "name" character varying(20) NOT NULL,
118         "extension" character varying(10) NOT NULL,
119         "mimetype" character varying(40) NOT NULL,
120         "commment" character varying(255)
121 );
122
123 --
124 -- TOC Entry ID 15 (OID 20030)
125 --
126 -- Name: img_layout Type: TABLE Owner: postgres
127 --
128
129 CREATE TABLE "img_layout" (
130         "id" smallint NOT NULL,
131         "name" character varying(20) NOT NULL
132 );
133
134 --
135 -- TOC Entry ID 16 (OID 20041)
136 --
137 -- Name: img_type Type: TABLE Owner: postgres
138 --
139
140 CREATE TABLE "img_type" (
141         "id" smallint NOT NULL,
142         "name" character varying(30) NOT NULL
143 );
144
145 --
146 -- TOC Entry ID 17 (OID 20052)
147 --
148 -- Name: img_color Type: TABLE Owner: postgres
149 --
150
151 CREATE TABLE "img_color" (
152         "id" smallint NOT NULL,
153         "name" character varying(30) NOT NULL
154 );
155
156 --
157 -- TOC Entry ID 18 (OID 20063)
158 --
159 -- Name: language Type: TABLE Owner: postgres
160 --
161
162 CREATE TABLE "language" (
163         "id" integer NOT NULL,
164         "name" character varying(40) NOT NULL,
165         "code" character varying(2) NOT NULL,
166         Constraint "language_pkey" Primary Key ("id")
167 );
168
169 --
170 -- TOC Entry ID 19 (OID 20078)
171 --
172 -- Name: rights Type: TABLE Owner: postgres
173 --
174
175 CREATE TABLE "rights" (
176         "id" integer NOT NULL,
177         "name" character varying(80) NOT NULL,
178         "description" text,
179         Constraint "rights_pkey" Primary Key ("id")
180 );
181
182 --
183 -- TOC Entry ID 20 (OID 20108)
184 --
185 -- Name: feature Type: TABLE Owner: postgres
186 --
187
188 CREATE TABLE "feature" (
189         "id" integer DEFAULT nextval('feature_id_seq'::text) NOT NULL,
190         "title" character varying(80) NOT NULL,
191         "description" text,
192         "filename" character varying(20) NOT NULL,
193         "main_url" character varying(255),
194         "is_published" boolean DEFAULT '0' NOT NULL,
195         Constraint "feature_pkey" Primary Key ("id")
196 );
197
198 --
199 -- TOC Entry ID 21 (OID 20143)
200 --
201 -- Name: webdb_users Type: TABLE Owner: postgres
202 --
203
204 CREATE TABLE "webdb_users" (
205         "id" integer DEFAULT nextval('webdb_users_id_seq'::text) NOT NULL,
206         "login" character varying(16) NOT NULL,
207         "password" character varying(16) NOT NULL,
208         "is_admin" boolean DEFAULT '0' NOT NULL,
209         Constraint "webdb_users_pkey" Primary Key ("id")
210 );
211
212 --
213 -- TOC Entry ID 22 (OID 20161)
214 --
215 -- Name: content_x_topic Type: TABLE Owner: postgres
216 --
217
218 CREATE TABLE "content_x_topic" (
219         "content_id" integer NOT NULL,
220         "topic_id" integer NOT NULL
221 );
222
223 --
224 -- TOC Entry ID 23 (OID 20172)
225 --
226 -- Name: article_type Type: TABLE Owner: postgres
227 --
228
229 CREATE TABLE "article_type" (
230         "id" integer NOT NULL,
231         "name" character varying(20) NOT NULL
232 );
233
234 --
235 -- TOC Entry ID 24 (OID 20183)
236 --
237 -- Name: topic Type: TABLE Owner: postgres
238 --
239
240 CREATE TABLE "topic" (
241         "id" integer DEFAULT nextval('topic_id_seq'::text) NOT NULL,
242         "parent_id" integer DEFAULT '0' NOT NULL,
243         "title" character varying(80) NOT NULL,
244         "description" text,
245         "filename" character varying(20) NOT NULL,
246         "main_url" character varying(255),
247         "archiv_url" character varying(255),
248         Constraint "topic_pkey" Primary Key ("id")
249 );
250
251 --
252 -- TOC Entry ID 25 (OID 20219)
253 --
254 -- Name: comment Type: TABLE Owner: postgres
255 --
256
257 CREATE TABLE "comment" (
258         "id" integer DEFAULT nextval('comment_id_seq'::text) NOT NULL,
259         "title" character varying(80) NOT NULL,
260         "creator" character varying(80) NOT NULL,
261         "description" text NOT NULL,
262         "main_url" character varying(255),
263         "email" character varying(80),
264         "address" character varying(80),
265         "phone" character varying(20),
266         "webdb_create" timestamp with time zone NOT NULL,
267         "is_published" boolean DEFAULT '1' NOT NULL,
268         "to_language" integer DEFAULT '0' NOT NULL,
269         "to_media" integer NOT NULL,
270         "to_comment_status" smallint,
271         "checksum" integer,
272         Constraint "comment_pkey" Primary Key ("id")
273 );
274
275 --
276 -- TOC Entry ID 26 (OID 20266)
277 --
278 -- Name: media Type: TABLE Owner: postgres
279 --
280
281 CREATE TABLE "media" (
282         "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
283         "title" character varying(80) NOT NULL,
284         "subtitle" character varying(30),
285         "edittitle" character varying(30),
286         "date" character(8) NOT NULL,
287         "creator" character varying(80),
288         "creator_main_url" character varying(255),
289         "creator_email" character varying(80),
290         "creator_address" character varying(80),
291         "creator_phone" character varying(20),
292         "description" text,
293         "keywords" text,
294         "comment" text,
295         "source" character varying(255),
296         "publish_date" timestamp with time zone,
297         "publish_server" character varying(255),
298         "publish_path" character varying(255),
299         "is_published" boolean DEFAULT '0' NOT NULL,
300         "is_produced" boolean DEFAULT '0' NOT NULL,
301         "to_feature" integer DEFAULT '0' NOT NULL,
302         "to_media_folder" integer DEFAULT '0' NOT NULL,
303         "to_media_type" smallint DEFAULT '0' NOT NULL,
304         "to_publisher" integer NOT NULL,
305         "to_language" integer DEFAULT '0',
306         "to_rights" integer DEFAULT '0',
307         "webdb_create" timestamp with time zone NOT NULL,
308         "webdb_lastchange" timestamp with time zone,
309         "to_media" integer
310 );
311
312 --
313 -- TOC Entry ID 27 (OID 20326)
314 --
315 -- Name: uploaded_media Type: TABLE Owner: postgres
316 --
317
318 CREATE TABLE "uploaded_media" (
319         "icon_is_produced" boolean DEFAULT '0' NOT NULL,
320         "icon_path" character varying(255),
321         "size" integer
322 )
323 INHERITS ("media");
324
325 --
326 -- TOC Entry ID 28 (OID 20392)
327 --
328 -- Name: images Type: TABLE Owner: postgres
329 --
330
331 CREATE TABLE "images" (
332         "image_data" oid,
333         "icon_data" oid,
334         "year" character varying(40),
335         "img_width" smallint,
336         "img_height" smallint,
337         "to_img_format" smallint DEFAULT '0' NOT NULL,
338         "to_img_layout" smallint DEFAULT '0' NOT NULL,
339         "to_img_type" smallint DEFAULT '0' NOT NULL,
340         "to_img_color" smallint DEFAULT '0' NOT NULL,
341         "icon_width" smallint,
342         "icon_height" smallint
343 )
344 INHERITS ("uploaded_media");
345
346 --
347 -- TOC Entry ID 29 (OID 20474)
348 --
349 -- Name: content Type: TABLE Owner: postgres
350 --
351
352 CREATE TABLE "content" (
353         "content_data" text,
354         "link_url" character varying(255),
355         "is_html" boolean DEFAULT '0' NOT NULL,
356         "is_stored" boolean DEFAULT '0' NOT NULL,
357         "to_article_type" smallint DEFAULT '0' NOT NULL,
358         "to_content" integer,
359         "checksum" integer
360 )
361 INHERITS ("media");
362
363 --
364 -- TOC Entry ID 30 (OID 20549)
365 --
366 -- Name: breaking Type: TABLE Owner: postgres
367 --
368
369 CREATE TABLE "breaking" (
370         "id" integer DEFAULT nextval('breaking_id_seq'::text) NOT NULL,
371         "text" character varying(255) NOT NULL,
372         "webdb_create" timestamp with time zone NOT NULL
373 );
374
375 --
376 -- TOC Entry ID 31 (OID 20562)
377 --
378 -- Name: messages Type: TABLE Owner: postgres
379 --
380
381 CREATE TABLE "messages" (
382         "id" integer DEFAULT nextval('messages_id_seq'::text) NOT NULL,
383         "title" character varying(30),
384         "description" character varying(255) NOT NULL,
385         "creator" character varying(30) NOT NULL,
386         "webdb_create" timestamp with time zone NOT NULL
387 );
388
389 --
390 -- TOC Entry ID 32 (OID 20577)
391 --
392 -- Name: comment_status Type: TABLE Owner: postgres
393 --
394
395 CREATE TABLE "comment_status" (
396         "id" smallint NOT NULL,
397         "name" character varying(40) NOT NULL
398 );
399
400 --
401 -- TOC Entry ID 33 (OID 20588)
402 --
403 -- Name: content_x_media Type: TABLE Owner: postgres
404 --
405
406 CREATE TABLE "content_x_media" (
407         "content_id" integer,
408         "media_id" integer
409 );
410
411 --
412 -- TOC Entry ID 11 (OID 20599)
413 --
414 -- Name: links_imcs_id_seq Type: SEQUENCE Owner: postgres
415 --
416
417 CREATE SEQUENCE "links_imcs_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
418
419 --
420 -- TOC Entry ID 34 (OID 20618)
421 --
422 -- Name: links_imcs Type: TABLE Owner: postgres
423 --
424
425 CREATE TABLE "links_imcs" (
426         "id" integer DEFAULT nextval('links_imcs_id_seq'::text) NOT NULL,
427         "to_parent_id" integer,
428         "title" character varying(80) NOT NULL,
429         "url" character varying(255) NOT NULL,
430         "sortpriority" integer DEFAULT '1',
431         "to_language" integer DEFAULT '0' NOT NULL,
432         Constraint "links_imcs_pkey" Primary Key ("id")
433 );
434
435 --
436 -- TOC Entry ID 35 (OID 37215)
437 --
438 -- Name: audio Type: TABLE Owner: postgres
439 --
440
441 CREATE TABLE "audio" (
442         "audio_data" oid,
443         "kbits" smallint
444 )
445 INHERITS ("uploaded_media");
446
447 --
448 -- TOC Entry ID 36 (OID 37284)
449 --
450 -- Name: video Type: TABLE Owner: postgres
451 --
452
453 CREATE TABLE "video" (
454         "video_data" oid
455 )
456 INHERITS ("uploaded_media");
457
458 --
459 -- TOC Entry ID 37 (OID 45396)
460 --
461 -- Name: other_media Type: TABLE Owner: postgres
462 --
463
464 CREATE TABLE "other_media" (
465         
466 )
467 INHERITS ("uploaded_media");
468
469 --
470 -- TOC Entry ID 40 (OID 20143)
471 --
472 -- Name: "idx_webdb_user_log_pas_is_admin" Type: INDEX Owner: postgres
473 --
474
475 CREATE  INDEX "idx_webdb_user_log_pas_is_admin" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops", "is_admin" "bool_ops" );
476
477 --
478 -- TOC Entry ID 41 (OID 20143)
479 --
480 -- Name: "idx_webdb_user_log_pas" Type: INDEX Owner: postgres
481 --
482
483 CREATE  INDEX "idx_webdb_user_log_pas" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops" );
484
485 --
486 -- TOC Entry ID 42 (OID 20161)
487 --
488 -- Name: "idx_content" Type: INDEX Owner: postgres
489 --
490
491 CREATE UNIQUE INDEX "idx_content" on "content_x_topic" using btree ( "content_id" "int4_ops", "topic_id" "int4_ops" );
492
493 --
494 -- TOC Entry ID 43 (OID 20161)
495 --
496 -- Name: "idx_topic" Type: INDEX Owner: postgres
497 --
498
499 CREATE UNIQUE INDEX "idx_topic" on "content_x_topic" using btree ( "topic_id" "int4_ops", "content_id" "int4_ops" );
500
501 --
502 -- TOC Entry ID 44 (OID 20183)
503 --
504 -- Name: "idx_topic_title" Type: INDEX Owner: postgres
505 --
506
507 CREATE  INDEX "idx_topic_title" on "topic" using btree ( "title" "varchar_ops" );
508
509 --
510 -- TOC Entry ID 45 (OID 20183)
511 --
512 -- Name: "idx_topic_id" Type: INDEX Owner: postgres
513 --
514
515 CREATE UNIQUE INDEX "idx_topic_id" on "topic" using btree ( "id" "int4_ops" );
516
517 --
518 -- TOC Entry ID 38 (OID 20219)
519 --
520 -- Name: "comment_checksum_index" Type: INDEX Owner: postgres
521 --
522
523 CREATE  INDEX "comment_checksum_index" on "comment" using btree ( "checksum" "int4_ops" );
524
525 --
526 -- TOC Entry ID 46 (OID 20219)
527 --
528 -- Name: "idx_comment_to_media" Type: INDEX Owner: postgres
529 --
530
531 CREATE  INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
532
533 --
534
535 --
536 -- TOC Entry ID 59 (OID 20326)
537 --
538 -- Name: "idx_uploaded_media_id" Type: INDEX Owner: postgres
539 --
540
541 CREATE UNIQUE INDEX "idx_uploaded_media_id" on "uploaded_media" using btree ( "id" "int4_ops" );
542
543 --
544 -- TOC Entry ID 60 (OID 20326)
545 --
546 -- Name: "idx_uploaded_media_is_published" Type: INDEX Owner: postgres
547 --
548
549 CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using btree ( "id" "int4_ops", "is_published" "bool_ops" );
550
551 --
552 -- TOC Entry ID 47 (OID 20392)
553 --
554 -- Name: "idx_images_is_published__icon_i" Type: INDEX Owner: postgres
555 --
556
557 CREATE  INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
558
559 --
560 -- TOC Entry ID 48 (OID 20392)
561 --
562 -- Name: "idx_images_id" Type: INDEX Owner: postgres
563 --
564
565 CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
566
567 --
568 -- TOC Entry ID 39 (OID 20474)
569 --
570 -- Name: "content_checksum_index" Type: INDEX Owner: postgres
571 --
572
573 CREATE  INDEX "content_checksum_index" on "content" using btree ( "checksum" "int4_ops" );
574
575 --
576 -- TOC Entry ID 49 (OID 20474)
577 --
578 -- Name: "idx_content_to_article_type" Type: INDEX Owner: postgres
579 --
580
581 CREATE  INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
582
583 --
584 -- TOC Entry ID 50 (OID 20474)
585 --
586 -- Name: "idx_content_is_produced" Type: INDEX Owner: postgres
587 --
588
589 CREATE  INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
590
591 --
592 -- TOC Entry ID 51 (OID 20474)
593 --
594 -- Name: "idx_content_is_published__to_ar" Type: INDEX Owner: postgres
595 --
596
597 CREATE  INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
598
599 --
600 -- TOC Entry ID 52 (OID 20474)
601 --
602 -- Name: "idx_content_is_stored" Type: INDEX Owner: postgres
603 --
604
605 CREATE  INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bool_ops" );
606
607 --
608 -- TOC Entry ID 53 (OID 20474)
609 --
610 -- Name: "idx_content_is_published__id" Type: INDEX Owner: postgres
611 --
612
613 CREATE  INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
614
615 --
616 -- TOC Entry ID 54 (OID 20474)
617 --
618 -- Name: "idx_content_is_pub__to_art__to_" Type: INDEX Owner: postgres
619 --
620
621 CREATE  INDEX "idx_content_is_pub__to_art__to_" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops", "id" "int4_ops" );
622
623 --
624 -- TOC Entry ID 55 (OID 20474)
625 --
626 -- Name: "idx_content_id" Type: INDEX Owner: postgres
627 --
628
629 CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" );
630
631 --
632 -- TOC Entry ID 56 (OID 20588)
633 --
634 -- Name: "idx_content_media" Type: INDEX Owner: postgres
635 --
636
637 CREATE UNIQUE INDEX "idx_content_media" on "content_x_media" using btree ( "content_id" "int4_ops", "media_id" "int4_ops" );
638
639 --
640 -- TOC Entry ID 57 (OID 20588)
641 --
642 -- Name: "idx_media_content" Type: INDEX Owner: postgres
643 --
644
645 CREATE UNIQUE INDEX "idx_media_content" on "content_x_media" using btree ( "media_id" "int4_ops", "content_id" "int4_ops" );
646
647 --
648 -- TOC Entry ID 62 (OID 37215)
649 --
650 -- Name: "idx_audio_is_published_produced" Type: INDEX Owner: postgres
651 --
652
653 CREATE  INDEX "idx_audio_is_published_produced" on "audio" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
654
655 --
656 -- TOC Entry ID 64 (OID 37215)
657 --
658 -- Name: "idx_audio_id" Type: INDEX Owner: postgres
659 --
660
661 CREATE UNIQUE INDEX "idx_audio_id" on "audio" using btree ( "id" "int4_ops" );
662
663 --
664 -- TOC Entry ID 65 (OID 37215)
665 --
666 -- Name: "idx_video_id" Type: INDEX Owner: postgres
667 --
668
669 CREATE UNIQUE INDEX "idx_video_id" on "audio" using btree ( "id" "int4_ops" );
670
671 --
672 -- TOC Entry ID 63 (OID 37284)
673 --
674 -- Name: "idx_video_is_published_produced" Type: INDEX Owner: postgres
675 --
676
677 CREATE  INDEX "idx_video_is_published_produced" on "video" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
678
679
680 --
681 -- TOC Entry ID 37 (OID 520246)
682 --
683 -- Name: "idx_content_is_published" Type: INDEX Owner: postgres
684 --
685
686 CREATE  INDEX "idx_content_is_published" on "content" using btree ( "is_published" "bool_ops" );
687
688 --
689 -- TOC Entry ID 47 (OID 465036)
690 --
691 -- Name: "idx_comment_tomedia_ispublished" Type: INDEX Owner: postgres
692 --
693
694 CREATE  INDEX "idx_comment_tomedia_ispublished" on "comment" using btree ( "to_media" "int4_ops", "is_published" "bool_ops" );
695
696