Moved the creation of the index on comment from the dupetrigger script to
[mir.git] / dbscripts / create_pg.sql
1 --
2 -- Selected TOC Entries:
3 --
4 \connect - postgres
5 --
6 -- TOC Entry ID 2 (OID 28714)
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 28733)
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 28752)
23 --
24 -- Name: creator_id_seq Type: SEQUENCE Owner: postgres
25 --
26
27 CREATE SEQUENCE "creator_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
28
29 --
30 -- TOC Entry ID 5 (OID 28771)
31 --
32 -- Name: feature_id_seq Type: SEQUENCE Owner: postgres
33 --
34
35 CREATE SEQUENCE "feature_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
36
37 --
38 -- TOC Entry ID 6 (OID 28790)
39 --
40 -- Name: topic_id_seq Type: SEQUENCE Owner: postgres
41 --
42
43 CREATE SEQUENCE "topic_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
44
45 --
46 -- TOC Entry ID 7 (OID 28809)
47 --
48 -- Name: webdb_users_id_seq Type: SEQUENCE Owner: postgres
49 --
50
51 CREATE SEQUENCE "webdb_users_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
52
53 --
54 -- TOC Entry ID 8 (OID 28828)
55 --
56 -- Name: comment_id_seq Type: SEQUENCE Owner: postgres
57 --
58
59 CREATE SEQUENCE "comment_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
60
61 --
62 -- TOC Entry ID 9 (OID 28847)
63 --
64 -- Name: breaking_id_seq Type: SEQUENCE Owner: postgres
65 --
66
67 CREATE SEQUENCE "breaking_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
68
69 --
70 -- TOC Entry ID 10 (OID 28866)
71 --
72 -- Name: messages_id_seq Type: SEQUENCE Owner: postgres
73 --
74
75 CREATE SEQUENCE "messages_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
76
77 --
78 -- TOC Entry ID 10 (OID 28866)
79 --
80 -- Name: media_type_id_seq Type: SEQUENCE Owner: postgres
81 --
82
83 CREATE SEQUENCE "media_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
84
85 --
86 -- TOC Entry ID 12 (OID 28885)
87 --
88 -- Name: media_folder Type: TABLE Owner: postgres
89 --
90
91 CREATE TABLE "media_folder" (
92         "id" integer DEFAULT nextval('media_folder_id_seq'::text) NOT NULL,
93         "name" character varying(255) NOT NULL,
94         "date" character(8) NOT NULL,
95         "place" character varying(80),
96         "keywords" text,
97         "comment" text,
98         "webdb_create" timestamp with time zone NOT NULL,
99         "webdb_lastchange" timestamp with time zone
100 );
101
102 --
103 -- TOC Entry ID 13 (OID 28918)
104 --
105 -- Name: media_type Type: TABLE Owner: postgres
106 --
107
108 CREATE TABLE "media_type" (
109         "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL,
110         "name" character varying(80) NOT NULL,
111         "mime_type" character varying(40) NOT NULL,
112         "classname" character varying(80) NOT NULL,
113         "tablename" character varying(80) NOT NULL,
114         "dcname" character varying(20)
115 );
116
117 --
118 -- TOC Entry ID 14 (OID 28932)
119 --
120 -- Name: img_format Type: TABLE Owner: postgres
121 --
122
123 CREATE TABLE "img_format" (
124         "id" smallint NOT NULL,
125         "name" character varying(20) NOT NULL,
126         "extension" character varying(10) NOT NULL,
127         "mimetype" character varying(40) NOT NULL,
128         "commment" character varying(255)
129 );
130
131 --
132 -- TOC Entry ID 15 (OID 28946)
133 --
134 -- Name: img_layout Type: TABLE Owner: postgres
135 --
136
137 CREATE TABLE "img_layout" (
138         "id" smallint NOT NULL,
139         "name" character varying(20) NOT NULL
140 );
141
142 --
143 -- TOC Entry ID 16 (OID 28957)
144 --
145 -- Name: img_type Type: TABLE Owner: postgres
146 --
147
148 CREATE TABLE "img_type" (
149         "id" smallint NOT NULL,
150         "name" character varying(30) NOT NULL
151 );
152
153 --
154 -- TOC Entry ID 17 (OID 28968)
155 --
156 -- Name: img_color Type: TABLE Owner: postgres
157 --
158
159 CREATE TABLE "img_color" (
160         "id" smallint NOT NULL,
161         "name" character varying(30) NOT NULL
162 );
163
164 --
165 -- TOC Entry ID 18 (OID 28979)
166 --
167 -- Name: language Type: TABLE Owner: postgres
168 --
169
170 CREATE TABLE "language" (
171         "id" integer NOT NULL,
172         "name" character varying(40) NOT NULL,
173         "code" character varying(2) NOT NULL,
174         Constraint "language_pkey" Primary Key ("id")
175 );
176
177 --
178 -- TOC Entry ID 19 (OID 28994)
179 --
180 -- Name: rights Type: TABLE Owner: postgres
181 --
182
183 CREATE TABLE "rights" (
184         "id" integer NOT NULL,
185         "name" character varying(80) NOT NULL,
186         "description" text,
187         Constraint "rights_pkey" Primary Key ("id")
188 );
189
190 --
191 -- TOC Entry ID 20 (OID 29024)
192 --
193 -- Name: creator Type: TABLE Owner: postgres
194 --
195
196 CREATE TABLE "creator" (
197         "id" integer DEFAULT nextval('creator_id_seq'::text) NOT NULL,
198         "name" character varying(80) NOT NULL,
199         "main_url" character varying(255),
200         "email" character varying(80),
201         "address" character varying(80),
202         "phone" character varying(20),
203         Constraint "creator_pkey" Primary Key ("id")
204 );
205
206 --
207 -- TOC Entry ID 21 (OID 29043)
208 --
209 -- Name: feature Type: TABLE Owner: postgres
210 --
211
212 CREATE TABLE "feature" (
213         "id" integer DEFAULT nextval('feature_id_seq'::text) NOT NULL,
214         "title" character varying(80) NOT NULL,
215         "description" text,
216         "filename" character varying(20) NOT NULL,
217         "main_url" character varying(255),
218         "is_published" boolean DEFAULT '0' NOT NULL,
219         Constraint "feature_pkey" Primary Key ("id")
220 );
221
222 --
223 -- TOC Entry ID 22 (OID 29078)
224 --
225 -- Name: webdb_users Type: TABLE Owner: postgres
226 --
227
228 CREATE TABLE "webdb_users" (
229         "id" integer DEFAULT nextval('webdb_users_id_seq'::text) NOT NULL,
230         "login" character varying(16) NOT NULL,
231         "password" character varying(16) NOT NULL,
232         "is_admin" boolean DEFAULT '0' NOT NULL,
233         Constraint "webdb_users_pkey" Primary Key ("id")
234 );
235
236 --
237 -- TOC Entry ID 23 (OID 29096)
238 --
239 -- Name: content_x_topic Type: TABLE Owner: postgres
240 --
241
242 CREATE TABLE "content_x_topic" (
243         "content_id" integer NOT NULL,
244         "topic_id" integer NOT NULL
245 );
246
247 --
248 -- TOC Entry ID 24 (OID 29107)
249 --
250 -- Name: article_type Type: TABLE Owner: postgres
251 --
252
253 CREATE TABLE "article_type" (
254         "id" integer NOT NULL,
255         "name" character varying(20) NOT NULL
256 );
257
258 --
259 -- TOC Entry ID 25 (OID 29118)
260 --
261 -- Name: topic Type: TABLE Owner: postgres
262 --
263
264 CREATE TABLE "topic" (
265         "id" integer DEFAULT nextval('topic_id_seq'::text) NOT NULL,
266         "parent_id" integer DEFAULT '0' NOT NULL,
267         "title" character varying(80) NOT NULL,
268         "description" text,
269         "filename" character varying(20) NOT NULL,
270         "main_url" character varying(255),
271         "archiv_url" character varying(255),
272         Constraint "topic_pkey" Primary Key ("id")
273 );
274
275 --
276 -- TOC Entry ID 26 (OID 29154)
277 --
278 -- Name: comment Type: TABLE Owner: postgres
279 --
280
281 CREATE TABLE "comment" (
282         "id" integer DEFAULT nextval('comment_id_seq'::text) NOT NULL,
283         "title" character varying(80) NOT NULL,
284         "creator" character varying(80) NOT NULL,
285         "description" text NOT NULL,
286         "main_url" character varying(255),
287         "email" character varying(80),
288         "address" character varying(80),
289         "phone" character varying(20),
290         "webdb_create" timestamp with time zone NOT NULL,
291         "is_published" boolean DEFAULT '1' NOT NULL,
292         "to_language" integer DEFAULT '0' NOT NULL,
293         "to_media" integer NOT NULL,
294         "to_comment_status" smallint,
295         "checksum" integer, 
296         Constraint "comment_pkey" Primary Key ("id")
297 );
298
299 CREATE INDEX comment_checksum_index ON comment (checksum);
300
301 --
302 -- TOC Entry ID 27 (OID 29196)
303 --
304 -- Name: media Type: TABLE Owner: postgres
305 --
306
307 CREATE TABLE "media" (
308         "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
309         "title" character varying(80) NOT NULL,
310         "subtitle" character varying(30),
311         "edittitle" character varying(30),
312         "date" character(8) NOT NULL,
313         "place" character varying(80),
314         "creator" character varying(80),
315         "creator_main_url" character varying(255),
316         "creator_email" character varying(80),
317         "creator_address" character varying(80),
318         "creator_phone" character varying(20),
319         "description" text,
320         "keywords" text,
321         "comment" text,
322         "source" character varying(255),
323         "publish_date" timestamp with time zone,
324         "publish_server" character varying(255),
325         "publish_path" character varying(255),
326         "is_published" boolean DEFAULT '0' NOT NULL,
327         "to_feature" integer DEFAULT '0' NOT NULL,
328         "to_media_folder" integer DEFAULT '0' NOT NULL,
329         "to_media_type" smallint DEFAULT '0' NOT NULL,
330         "to_creator" integer DEFAULT '0' NOT NULL,
331         "to_publisher" integer NOT NULL,
332         "to_language" integer DEFAULT '0',
333         "to_rights" integer DEFAULT '0',
334         "webdb_create" timestamp with time zone NOT NULL,
335         "webdb_lastchange" timestamp with time zone,
336         "to_media" integer
337 );
338
339 --
340 -- TOC Entry ID 28 (OID 29257)
341 --
342 -- Name: images Type: TABLE Owner: postgres
343 --
344
345 CREATE TABLE "images" (
346         "image_data" oid,
347         "icon_data" oid,
348         "icon_path" character varying(255),
349         "icon_is_produced" boolean DEFAULT '0' NOT NULL,
350         "year" character varying(40),
351         "img_width" smallint,
352         "img_height" smallint,
353         "to_img_format" smallint DEFAULT '0' NOT NULL,
354         "to_img_layout" smallint DEFAULT '0' NOT NULL,
355         "to_img_type" smallint DEFAULT '0' NOT NULL,
356         "to_img_color" smallint DEFAULT '0' NOT NULL,
357         "icon_width" smallint,
358         "icon_height" smallint
359 )
360 INHERITS ("media");
361
362 --
363 -- TOC Entry ID 29 (OID 29338)
364 --
365 -- Name: content Type: TABLE Owner: postgres
366 --
367
368 CREATE TABLE "content" (
369         "content_data" text,
370         "link_url" character varying(255),
371         "date_from" character varying(8),
372         "date_to" character varying(8),
373         "date_name" character varying(255),
374         "is_html" boolean DEFAULT '0' NOT NULL,
375         "is_produced" boolean DEFAULT '0' NOT NULL,
376         "is_stored" boolean DEFAULT '0' NOT NULL,
377         "is_mail_sent" boolean DEFAULT '1' NOT NULL,
378         "is_digest_sent" boolean DEFAULT '1' NOT NULL,
379         "to_article_type" smallint DEFAULT '0' NOT NULL,
380         "to_content" integer
381 )
382 INHERITS ("media");
383
384 --
385 -- TOC Entry ID 30 (OID 29418)
386 --
387 -- Name: breaking Type: TABLE Owner: postgres
388 --
389
390 CREATE TABLE "breaking" (
391         "id" integer DEFAULT nextval('breaking_id_seq'::text) NOT NULL,
392         "text" character varying(255) NOT NULL,
393         "webdb_create" timestamp with time zone NOT NULL
394 );
395
396 --
397 -- TOC Entry ID 31 (OID 29431)
398 --
399 -- Name: messages Type: TABLE Owner: postgres
400 --
401
402 CREATE TABLE "messages" (
403         "id" integer DEFAULT nextval('messages_id_seq'::text) NOT NULL,
404         "title" character varying(30),
405         "description" character varying(255) NOT NULL,
406         "creator" character varying(30) NOT NULL,
407         "webdb_create" timestamp with time zone NOT NULL
408 );
409
410 --
411 -- TOC Entry ID 32 (OID 29446)
412 --
413 -- Name: uploaded_media Type: TABLE Owner: postgres
414 --
415
416 CREATE TABLE "uploaded_media" (
417  
418 ) INHERITS ("media");
419
420 --
421 -- TOC Entry ID 33 (OID 30026)
422 --
423 -- Name: comment_status Type: TABLE Owner: postgres
424 --
425
426 CREATE TABLE "comment_status" (
427         "id" smallint NOT NULL,
428         "name" character varying(40) NOT NULL
429 );
430
431 --
432 -- TOC Entry ID 34 (OID 30064)
433 --
434 -- Name: content_x_media Type: TABLE Owner: postgres
435 --
436
437 CREATE TABLE "content_x_media" (
438         "content_id" integer,
439         "media_id" integer
440 );
441
442 --
443 -- TOC Entry ID 11 (OID 32812)
444 --
445 -- Name: links_imcs_id_seq Type: SEQUENCE Owner: postgres
446 --
447
448 CREATE SEQUENCE "links_imcs_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
449
450 --
451 -- TOC Entry ID 35 (OID 32831)
452 --
453 -- Name: links_imcs Type: TABLE Owner: postgres
454 --
455
456 CREATE TABLE "links_imcs" (
457         "id" integer DEFAULT nextval('links_imcs_id_seq'::text) NOT NULL,
458         "to_parent_id" integer,
459         "title" character varying(80) NOT NULL,
460         "url" character varying(255) NOT NULL,
461         "sortpriority" integer DEFAULT '1',
462         "to_language" integer DEFAULT '0' NOT NULL,
463         Constraint "links_imcs_pkey" Primary Key ("id")
464 );
465
466 --
467 -- TOC Entry ID 40 (OID 29078)
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 44 (OID 29078)
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 43 (OID 29096)
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 45 (OID 29096)
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 46 (OID 29118)
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 51 (OID 29118)
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 36 (OID 29154)
516 --
517 -- Name: "idx_comment_to_media" Type: INDEX Owner: postgres
518 --
519
520 CREATE  INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
521
522 --
523 -- TOC Entry ID 47 (OID 29257)
524 --
525 -- Name: "idx_images_is_published__icon_i" Type: INDEX Owner: postgres
526 --
527
528 CREATE  INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
529
530 --
531 -- TOC Entry ID 49 (OID 29257)
532 --
533 -- Name: "idx_images_id" Type: INDEX Owner: postgres
534 --
535
536 CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
537
538 --
539 -- TOC Entry ID 37 (OID 29338)
540 --
541 -- Name: "idx_content_to_article_type" Type: INDEX Owner: postgres
542 --
543
544 CREATE  INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
545
546 --
547 -- TOC Entry ID 38 (OID 29338)
548 --
549 -- Name: "idx_content_is_produced" Type: INDEX Owner: postgres
550 --
551
552 CREATE  INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
553
554 --
555 -- TOC Entry ID 39 (OID 29338)
556 --
557 -- Name: "idx_content_is_published__to_ar" Type: INDEX Owner: postgres
558 --
559
560 CREATE  INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
561
562 --
563 -- TOC Entry ID 41 (OID 29338)
564 --
565 -- Name: "idx_content_is_stored" Type: INDEX Owner: postgres
566 --
567
568 CREATE  INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bool_ops" );
569
570 --
571 -- TOC Entry ID 42 (OID 29338)
572 --
573 -- Name: "idx_content_is_published__id" Type: INDEX Owner: postgres
574 --
575
576 CREATE  INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
577
578 --
579 -- TOC Entry ID 48 (OID 29338)
580 --
581 -- Name: "idx_content_is_pub__to_art__to_" Type: INDEX Owner: postgres
582 --
583
584 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" );
585
586 --
587 -- TOC Entry ID 50 (OID 29338)
588 --
589 -- Name: "idx_content_id" Type: INDEX Owner: postgres
590 --
591
592 CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" );
593
594 --
595 -- TOC Entry ID 52 (OID 30064)
596 --
597 -- Name: "idx_content_media" Type: INDEX Owner: postgres
598 --
599
600 CREATE UNIQUE INDEX "idx_content_media" on "content_x_media" using btree ( "content_id" "int4_ops", "media_id" "int4_ops" );
601
602 --
603 -- TOC Entry ID 53 (OID 30064)
604 --
605 -- Name: "idx_media_content" Type: INDEX Owner: postgres
606 --
607
608 CREATE UNIQUE INDEX "idx_media_content" on "content_x_media" using btree ( "media_id" "int4_ops", "content_id" "int4_ops" );
609