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