media-upload
[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         Constraint "comment_pkey" Primary Key ("id")
296 );
297
298 --
299 -- TOC Entry ID 27 (OID 29196)
300 --
301 -- Name: media Type: TABLE Owner: postgres
302 --
303
304 CREATE TABLE "media" (
305         "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
306         "title" character varying(80) NOT NULL,
307         "subtitle" character varying(30),
308         "edittitle" character varying(30),
309         "date" character(8) NOT NULL,
310         "place" character varying(80),
311         "creator" character varying(80),
312         "creator_main_url" character varying(255),
313         "creator_email" character varying(80),
314         "creator_address" character varying(80),
315         "creator_phone" character varying(20),
316         "description" text,
317         "keywords" text,
318         "comment" text,
319         "source" character varying(255),
320         "publish_date" timestamp with time zone,
321         "publish_server" character varying(255),
322         "publish_path" character varying(255),
323         "is_published" boolean DEFAULT '0' NOT NULL,
324         "to_feature" integer DEFAULT '0' NOT NULL,
325         "to_media_folder" integer DEFAULT '0' NOT NULL,
326         "to_media_type" smallint DEFAULT '0' NOT NULL,
327         "to_creator" integer DEFAULT '0' NOT NULL,
328         "to_publisher" integer NOT NULL,
329         "to_language" integer DEFAULT '0',
330         "to_rights" integer DEFAULT '0',
331         "webdb_create" timestamp with time zone NOT NULL,
332         "webdb_lastchange" timestamp with time zone,
333         "to_media" integer
334 );
335
336 --
337 -- TOC Entry ID 28 (OID 29257)
338 --
339 -- Name: images Type: TABLE Owner: postgres
340 --
341
342 CREATE TABLE "images" (
343         "image_data" oid,
344         "icon_data" oid,
345         "icon_path" character varying(255),
346         "icon_is_produced" boolean DEFAULT '0' NOT NULL,
347         "year" character varying(40),
348         "img_width" smallint,
349         "img_height" smallint,
350         "to_img_format" smallint DEFAULT '0' NOT NULL,
351         "to_img_layout" smallint DEFAULT '0' NOT NULL,
352         "to_img_type" smallint DEFAULT '0' NOT NULL,
353         "to_img_color" smallint DEFAULT '0' NOT NULL,
354         "icon_width" smallint,
355         "icon_height" smallint
356 )
357 INHERITS ("media");
358
359 --
360 -- TOC Entry ID 29 (OID 29338)
361 --
362 -- Name: content Type: TABLE Owner: postgres
363 --
364
365 CREATE TABLE "content" (
366         "content_data" text,
367         "link_url" character varying(255),
368         "date_from" character varying(8),
369         "date_to" character varying(8),
370         "date_name" character varying(255),
371         "is_html" boolean DEFAULT '0' NOT NULL,
372         "is_produced" boolean DEFAULT '0' NOT NULL,
373         "is_stored" boolean DEFAULT '0' NOT NULL,
374         "is_mail_sent" boolean DEFAULT '1' NOT NULL,
375         "is_digest_sent" boolean DEFAULT '1' NOT NULL,
376         "to_article_type" smallint DEFAULT '0' NOT NULL,
377         "to_content" integer
378 )
379 INHERITS ("media");
380
381 --
382 -- TOC Entry ID 30 (OID 29418)
383 --
384 -- Name: breaking Type: TABLE Owner: postgres
385 --
386
387 CREATE TABLE "breaking" (
388         "id" integer DEFAULT nextval('breaking_id_seq'::text) NOT NULL,
389         "text" character varying(255) NOT NULL,
390         "webdb_create" timestamp with time zone NOT NULL
391 );
392
393 --
394 -- TOC Entry ID 31 (OID 29431)
395 --
396 -- Name: messages Type: TABLE Owner: postgres
397 --
398
399 CREATE TABLE "messages" (
400         "id" integer DEFAULT nextval('messages_id_seq'::text) NOT NULL,
401         "title" character varying(30),
402         "description" character varying(255) NOT NULL,
403         "creator" character varying(30) NOT NULL,
404         "webdb_create" timestamp with time zone NOT NULL
405 );
406
407 --
408 -- TOC Entry ID 32 (OID 29446)
409 --
410 -- Name: uploaded_media Type: TABLE Owner: postgres
411 --
412
413 CREATE TABLE "uploaded_media" (
414  
415 ) INHERITS ("media");
416
417 --
418 -- TOC Entry ID 33 (OID 30026)
419 --
420 -- Name: comment_status Type: TABLE Owner: postgres
421 --
422
423 CREATE TABLE "comment_status" (
424         "id" smallint NOT NULL,
425         "name" character varying(40) NOT NULL
426 );
427
428 --
429 -- TOC Entry ID 34 (OID 30064)
430 --
431 -- Name: content_x_media Type: TABLE Owner: postgres
432 --
433
434 CREATE TABLE "content_x_media" (
435         "content_id" integer,
436         "media_id" integer
437 );
438
439 --
440 -- TOC Entry ID 11 (OID 32812)
441 --
442 -- Name: links_imcs_id_seq Type: SEQUENCE Owner: postgres
443 --
444
445 CREATE SEQUENCE "links_imcs_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
446
447 --
448 -- TOC Entry ID 35 (OID 32831)
449 --
450 -- Name: links_imcs Type: TABLE Owner: postgres
451 --
452
453 CREATE TABLE "links_imcs" (
454         "id" integer DEFAULT nextval('links_imcs_id_seq'::text) NOT NULL,
455         "to_parent_id" integer,
456         "title" character varying(80) NOT NULL,
457         "url" character varying(255) NOT NULL,
458         "sortpriority" integer DEFAULT '1',
459         "to_language" integer DEFAULT '0' NOT NULL,
460         Constraint "links_imcs_pkey" Primary Key ("id")
461 );
462
463 --
464 -- TOC Entry ID 40 (OID 29078)
465 --
466 -- Name: "idx_webdb_user_log_pas_is_admin" Type: INDEX Owner: postgres
467 --
468
469 CREATE  INDEX "idx_webdb_user_log_pas_is_admin" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops", "is_admin" "bool_ops" );
470
471 --
472 -- TOC Entry ID 44 (OID 29078)
473 --
474 -- Name: "idx_webdb_user_log_pas" Type: INDEX Owner: postgres
475 --
476
477 CREATE  INDEX "idx_webdb_user_log_pas" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops" );
478
479 --
480 -- TOC Entry ID 43 (OID 29096)
481 --
482 -- Name: "idx_content" Type: INDEX Owner: postgres
483 --
484
485 CREATE UNIQUE INDEX "idx_content" on "content_x_topic" using btree ( "content_id" "int4_ops", "topic_id" "int4_ops" );
486
487 --
488 -- TOC Entry ID 45 (OID 29096)
489 --
490 -- Name: "idx_topic" Type: INDEX Owner: postgres
491 --
492
493 CREATE UNIQUE INDEX "idx_topic" on "content_x_topic" using btree ( "topic_id" "int4_ops", "content_id" "int4_ops" );
494
495 --
496 -- TOC Entry ID 46 (OID 29118)
497 --
498 -- Name: "idx_topic_title" Type: INDEX Owner: postgres
499 --
500
501 CREATE  INDEX "idx_topic_title" on "topic" using btree ( "title" "varchar_ops" );
502
503 --
504 -- TOC Entry ID 51 (OID 29118)
505 --
506 -- Name: "idx_topic_id" Type: INDEX Owner: postgres
507 --
508
509 CREATE UNIQUE INDEX "idx_topic_id" on "topic" using btree ( "id" "int4_ops" );
510
511 --
512 -- TOC Entry ID 36 (OID 29154)
513 --
514 -- Name: "idx_comment_to_media" Type: INDEX Owner: postgres
515 --
516
517 CREATE  INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
518
519 --
520 -- TOC Entry ID 47 (OID 29257)
521 --
522 -- Name: "idx_images_is_published__icon_i" Type: INDEX Owner: postgres
523 --
524
525 CREATE  INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
526
527 --
528 -- TOC Entry ID 49 (OID 29257)
529 --
530 -- Name: "idx_images_id" Type: INDEX Owner: postgres
531 --
532
533 CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
534
535 --
536 -- TOC Entry ID 37 (OID 29338)
537 --
538 -- Name: "idx_content_to_article_type" Type: INDEX Owner: postgres
539 --
540
541 CREATE  INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
542
543 --
544 -- TOC Entry ID 38 (OID 29338)
545 --
546 -- Name: "idx_content_is_produced" Type: INDEX Owner: postgres
547 --
548
549 CREATE  INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
550
551 --
552 -- TOC Entry ID 39 (OID 29338)
553 --
554 -- Name: "idx_content_is_published__to_ar" Type: INDEX Owner: postgres
555 --
556
557 CREATE  INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
558
559 --
560 -- TOC Entry ID 41 (OID 29338)
561 --
562 -- Name: "idx_content_is_stored" Type: INDEX Owner: postgres
563 --
564
565 CREATE  INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bool_ops" );
566
567 --
568 -- TOC Entry ID 42 (OID 29338)
569 --
570 -- Name: "idx_content_is_published__id" Type: INDEX Owner: postgres
571 --
572
573 CREATE  INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
574
575 --
576 -- TOC Entry ID 48 (OID 29338)
577 --
578 -- Name: "idx_content_is_pub__to_art__to_" Type: INDEX Owner: postgres
579 --
580
581 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" );
582
583 --
584 -- TOC Entry ID 50 (OID 29338)
585 --
586 -- Name: "idx_content_id" Type: INDEX Owner: postgres
587 --
588
589 CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" );
590
591 --
592 -- TOC Entry ID 52 (OID 30064)
593 --
594 -- Name: "idx_content_media" Type: INDEX Owner: postgres
595 --
596
597 CREATE UNIQUE INDEX "idx_content_media" on "content_x_media" using btree ( "content_id" "int4_ops", "media_id" "int4_ops" );
598
599 --
600 -- TOC Entry ID 53 (OID 30064)
601 --
602 -- Name: "idx_media_content" Type: INDEX Owner: postgres
603 --
604
605 CREATE UNIQUE INDEX "idx_media_content" on "content_x_media" using btree ( "media_id" "int4_ops", "content_id" "int4_ops" );
606