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 12 (OID 28885)
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 28918)
96 --
97 -- Name: media_type Type: TABLE Owner: postgres
98 --
99
100 CREATE TABLE "media_type" (
101         "id" smallint 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 28932)
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 28946)
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 28957)
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 28968)
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 28979)
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 28994)
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 29024)
184 --
185 -- Name: creator Type: TABLE Owner: postgres
186 --
187
188 CREATE TABLE "creator" (
189         "id" integer DEFAULT nextval('creator_id_seq'::text) NOT NULL,
190         "name" character varying(80) NOT NULL,
191         "main_url" character varying(255),
192         "email" character varying(80),
193         "address" character varying(80),
194         "phone" character varying(20),
195         Constraint "creator_pkey" Primary Key ("id")
196 );
197
198 --
199 -- TOC Entry ID 21 (OID 29043)
200 --
201 -- Name: feature Type: TABLE Owner: postgres
202 --
203
204 CREATE TABLE "feature" (
205         "id" integer DEFAULT nextval('feature_id_seq'::text) NOT NULL,
206         "title" character varying(80) NOT NULL,
207         "description" text,
208         "filename" character varying(20) NOT NULL,
209         "main_url" character varying(255),
210         "is_published" boolean DEFAULT '0' NOT NULL,
211         Constraint "feature_pkey" Primary Key ("id")
212 );
213
214 --
215 -- TOC Entry ID 22 (OID 29078)
216 --
217 -- Name: webdb_users Type: TABLE Owner: postgres
218 --
219
220 CREATE TABLE "webdb_users" (
221         "id" integer DEFAULT nextval('webdb_users_id_seq'::text) NOT NULL,
222         "login" character varying(16) NOT NULL,
223         "password" character varying(16) NOT NULL,
224         "is_admin" boolean DEFAULT '0' NOT NULL,
225         Constraint "webdb_users_pkey" Primary Key ("id")
226 );
227
228 --
229 -- TOC Entry ID 23 (OID 29096)
230 --
231 -- Name: content_x_topic Type: TABLE Owner: postgres
232 --
233
234 CREATE TABLE "content_x_topic" (
235         "content_id" integer NOT NULL,
236         "topic_id" integer NOT NULL
237 );
238
239 --
240 -- TOC Entry ID 24 (OID 29107)
241 --
242 -- Name: article_type Type: TABLE Owner: postgres
243 --
244
245 CREATE TABLE "article_type" (
246         "id" integer NOT NULL,
247         "name" character varying(20) NOT NULL
248 );
249
250 --
251 -- TOC Entry ID 25 (OID 29118)
252 --
253 -- Name: topic Type: TABLE Owner: postgres
254 --
255
256 CREATE TABLE "topic" (
257         "id" integer DEFAULT nextval('topic_id_seq'::text) NOT NULL,
258         "parent_id" integer DEFAULT '0' NOT NULL,
259         "title" character varying(80) NOT NULL,
260         "description" text,
261         "filename" character varying(20) NOT NULL,
262         "main_url" character varying(255),
263         "archiv_url" character varying(255),
264         Constraint "topic_pkey" Primary Key ("id")
265 );
266
267 --
268 -- TOC Entry ID 26 (OID 29154)
269 --
270 -- Name: comment Type: TABLE Owner: postgres
271 --
272
273 CREATE TABLE "comment" (
274         "id" integer DEFAULT nextval('comment_id_seq'::text) NOT NULL,
275         "title" character varying(80) NOT NULL,
276         "creator" character varying(80) NOT NULL,
277         "description" text NOT NULL,
278         "main_url" character varying(255),
279         "email" character varying(80),
280         "address" character varying(80),
281         "phone" character varying(20),
282         "webdb_create" timestamp with time zone NOT NULL,
283         "is_published" boolean DEFAULT '1' NOT NULL,
284         "to_language" integer DEFAULT '0' NOT NULL,
285         "to_media" integer NOT NULL,
286         "to_comment_status" smallint,
287         Constraint "comment_pkey" Primary Key ("id")
288 );
289
290 --
291 -- TOC Entry ID 27 (OID 29196)
292 --
293 -- Name: media Type: TABLE Owner: postgres
294 --
295
296 CREATE TABLE "media" (
297         "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
298         "title" character varying(80) NOT NULL,
299         "subtitle" character varying(30),
300         "edittitle" character varying(30),
301         "date" character(8) NOT NULL,
302         "place" character varying(80),
303         "creator" character varying(80),
304         "creator_main_url" character varying(255),
305         "creator_email" character varying(80),
306         "creator_address" character varying(80),
307         "creator_phone" character varying(20),
308         "description" text,
309         "keywords" text,
310         "comment" text,
311         "source" character varying(255),
312         "publish_date" timestamp with time zone,
313         "publish_server" character varying(255),
314         "publish_path" character varying(255),
315         "is_published" boolean DEFAULT '0' NOT NULL,
316         "to_feature" integer DEFAULT '0' NOT NULL,
317         "to_media_folder" integer DEFAULT '0' NOT NULL,
318         "to_media_type" smallint DEFAULT '0' NOT NULL,
319         "to_creator" integer DEFAULT '0' NOT NULL,
320         "to_publisher" integer NOT NULL,
321         "to_language" integer DEFAULT '0',
322         "to_rights" integer DEFAULT '0',
323         "webdb_create" timestamp with time zone NOT NULL,
324         "webdb_lastchange" timestamp with time zone,
325         "to_media" integer
326 );
327
328 --
329 -- TOC Entry ID 28 (OID 29257)
330 --
331 -- Name: images Type: TABLE Owner: postgres
332 --
333
334 CREATE TABLE "images" (
335         "image_data" oid,
336         "icon_data" oid,
337         "icon_path" character varying(255),
338         "icon_is_produced" boolean DEFAULT '0' NOT NULL,
339         "year" character varying(40),
340         "img_width" smallint,
341         "img_height" smallint,
342         "to_img_format" smallint DEFAULT '0' NOT NULL,
343         "to_img_layout" smallint DEFAULT '0' NOT NULL,
344         "to_img_type" smallint DEFAULT '0' NOT NULL,
345         "to_img_color" smallint DEFAULT '0' NOT NULL,
346         "icon_width" smallint,
347         "icon_height" smallint
348 )
349 INHERITS ("media");
350
351 --
352 -- TOC Entry ID 29 (OID 29338)
353 --
354 -- Name: content Type: TABLE Owner: postgres
355 --
356
357 CREATE TABLE "content" (
358         "content_data" text,
359         "link_url" character varying(255),
360         "date_from" character varying(8),
361         "date_to" character varying(8),
362         "date_name" character varying(255),
363         "is_html" boolean DEFAULT '0' NOT NULL,
364         "is_produced" boolean DEFAULT '0' NOT NULL,
365         "is_stored" boolean DEFAULT '0' NOT NULL,
366         "is_mail_sent" boolean DEFAULT '1' NOT NULL,
367         "is_digest_sent" boolean DEFAULT '1' NOT NULL,
368         "to_article_type" smallint DEFAULT '0' NOT NULL,
369         "to_content" integer
370 )
371 INHERITS ("media");
372
373 --
374 -- TOC Entry ID 30 (OID 29418)
375 --
376 -- Name: breaking Type: TABLE Owner: postgres
377 --
378
379 CREATE TABLE "breaking" (
380         "id" integer DEFAULT nextval('breaking_id_seq'::text) NOT NULL,
381         "text" character varying(255) NOT NULL,
382         "webdb_create" timestamp with time zone NOT NULL
383 );
384
385 --
386 -- TOC Entry ID 31 (OID 29431)
387 --
388 -- Name: messages Type: TABLE Owner: postgres
389 --
390
391 CREATE TABLE "messages" (
392         "id" integer DEFAULT nextval('messages_id_seq'::text) NOT NULL,
393         "title" character varying(30),
394         "description" character varying(255) NOT NULL,
395         "creator" character varying(30) NOT NULL,
396         "webdb_create" timestamp with time zone NOT NULL
397 );
398
399 --
400 -- TOC Entry ID 32 (OID 29446)
401 --
402 -- Name: uploaded_media Type: TABLE Owner: postgres
403 --
404
405 CREATE TABLE "uploaded_media" (
406  
407 ) INHERITS ("media");
408
409 --
410 -- TOC Entry ID 33 (OID 30026)
411 --
412 -- Name: comment_status Type: TABLE Owner: postgres
413 --
414
415 CREATE TABLE "comment_status" (
416         "id" smallint NOT NULL,
417         "name" character varying(40) NOT NULL
418 );
419
420 --
421 -- TOC Entry ID 34 (OID 30064)
422 --
423 -- Name: content_x_media Type: TABLE Owner: postgres
424 --
425
426 CREATE TABLE "content_x_media" (
427         "content_id" integer,
428         "media_id" integer
429 );
430
431 --
432 -- TOC Entry ID 11 (OID 32812)
433 --
434 -- Name: links_imcs_id_seq Type: SEQUENCE Owner: postgres
435 --
436
437 CREATE SEQUENCE "links_imcs_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
438
439 --
440 -- TOC Entry ID 35 (OID 32831)
441 --
442 -- Name: links_imcs Type: TABLE Owner: postgres
443 --
444
445 CREATE TABLE "links_imcs" (
446         "id" integer DEFAULT nextval('links_imcs_id_seq'::text) NOT NULL,
447         "to_parent_id" integer,
448         "title" character varying(80) NOT NULL,
449         "url" character varying(255) NOT NULL,
450         "sortpriority" integer DEFAULT '1',
451         "to_language" integer DEFAULT '0' NOT NULL,
452         Constraint "links_imcs_pkey" Primary Key ("id")
453 );
454
455 --
456 -- TOC Entry ID 40 (OID 29078)
457 --
458 -- Name: "idx_webdb_user_log_pas_is_admin" Type: INDEX Owner: postgres
459 --
460
461 CREATE  INDEX "idx_webdb_user_log_pas_is_admin" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops", "is_admin" "bool_ops" );
462
463 --
464 -- TOC Entry ID 44 (OID 29078)
465 --
466 -- Name: "idx_webdb_user_log_pas" Type: INDEX Owner: postgres
467 --
468
469 CREATE  INDEX "idx_webdb_user_log_pas" on "webdb_users" using btree ( "login" "varchar_ops", "password" "varchar_ops" );
470
471 --
472 -- TOC Entry ID 43 (OID 29096)
473 --
474 -- Name: "idx_content" Type: INDEX Owner: postgres
475 --
476
477 CREATE UNIQUE INDEX "idx_content" on "content_x_topic" using btree ( "content_id" "int4_ops", "topic_id" "int4_ops" );
478
479 --
480 -- TOC Entry ID 45 (OID 29096)
481 --
482 -- Name: "idx_topic" Type: INDEX Owner: postgres
483 --
484
485 CREATE UNIQUE INDEX "idx_topic" on "content_x_topic" using btree ( "topic_id" "int4_ops", "content_id" "int4_ops" );
486
487 --
488 -- TOC Entry ID 46 (OID 29118)
489 --
490 -- Name: "idx_topic_title" Type: INDEX Owner: postgres
491 --
492
493 CREATE  INDEX "idx_topic_title" on "topic" using btree ( "title" "varchar_ops" );
494
495 --
496 -- TOC Entry ID 51 (OID 29118)
497 --
498 -- Name: "idx_topic_id" Type: INDEX Owner: postgres
499 --
500
501 CREATE UNIQUE INDEX "idx_topic_id" on "topic" using btree ( "id" "int4_ops" );
502
503 --
504 -- TOC Entry ID 36 (OID 29154)
505 --
506 -- Name: "idx_comment_to_media" Type: INDEX Owner: postgres
507 --
508
509 CREATE  INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
510
511 --
512 -- TOC Entry ID 47 (OID 29257)
513 --
514 -- Name: "idx_images_is_published__icon_i" Type: INDEX Owner: postgres
515 --
516
517 CREATE  INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
518
519 --
520 -- TOC Entry ID 49 (OID 29257)
521 --
522 -- Name: "idx_images_id" Type: INDEX Owner: postgres
523 --
524
525 CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
526
527 --
528 -- TOC Entry ID 37 (OID 29338)
529 --
530 -- Name: "idx_content_to_article_type" Type: INDEX Owner: postgres
531 --
532
533 CREATE  INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
534
535 --
536 -- TOC Entry ID 38 (OID 29338)
537 --
538 -- Name: "idx_content_is_produced" Type: INDEX Owner: postgres
539 --
540
541 CREATE  INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
542
543 --
544 -- TOC Entry ID 39 (OID 29338)
545 --
546 -- Name: "idx_content_is_published__to_ar" Type: INDEX Owner: postgres
547 --
548
549 CREATE  INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
550
551 --
552 -- TOC Entry ID 41 (OID 29338)
553 --
554 -- Name: "idx_content_is_stored" Type: INDEX Owner: postgres
555 --
556
557 CREATE  INDEX "idx_content_is_stored" on "content" using btree ( "is_stored" "bool_ops" );
558
559 --
560 -- TOC Entry ID 42 (OID 29338)
561 --
562 -- Name: "idx_content_is_published__id" Type: INDEX Owner: postgres
563 --
564
565 CREATE  INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
566
567 --
568 -- TOC Entry ID 48 (OID 29338)
569 --
570 -- Name: "idx_content_is_pub__to_art__to_" Type: INDEX Owner: postgres
571 --
572
573 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" );
574
575 --
576 -- TOC Entry ID 50 (OID 29338)
577 --
578 -- Name: "idx_content_id" Type: INDEX Owner: postgres
579 --
580
581 CREATE UNIQUE INDEX "idx_content_id" on "content" using btree ( "id" "int4_ops" );
582
583 --
584 -- TOC Entry ID 52 (OID 30064)
585 --
586 -- Name: "idx_content_media" Type: INDEX Owner: postgres
587 --
588
589 CREATE UNIQUE INDEX "idx_content_media" on "content_x_media" using btree ( "content_id" "int4_ops", "media_id" "int4_ops" );
590
591 --
592 -- TOC Entry ID 53 (OID 30064)
593 --
594 -- Name: "idx_media_content" Type: INDEX Owner: postgres
595 --
596
597 CREATE UNIQUE INDEX "idx_media_content" on "content_x_media" using btree ( "media_id" "int4_ops", "content_id" "int4_ops" );
598