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