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