update line for ogg support
[mir.git] / dbscripts / create_pg.sql
1 --
2 -- media_folder
3 --
4
5 CREATE SEQUENCE "media_folder_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
6
7 CREATE TABLE "media_folder" (
8         "id" integer DEFAULT nextval('media_folder_id_seq'::text) NOT NULL,
9         "name" character varying(255) NOT NULL,
10         "date" character(8) NOT NULL,
11         "place" character varying(80),
12         "keywords" text,
13         "comment" text,
14         "webdb_create" timestamp with time zone NOT NULL,
15         "webdb_lastchange" timestamp with time zone
16 );
17
18 --
19 -- media_type
20 --
21
22 CREATE SEQUENCE "media_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
23
24 CREATE TABLE "media_type" (
25         "id" integer DEFAULT nextval('media_type_id_seq'::text) NOT NULL,
26         "name" character varying(80) NOT NULL,
27         "mime_type" character varying(40) NOT NULL,
28         "classname" character varying(80) NOT NULL,
29         "tablename" character varying(80) NOT NULL,
30         "dcname" character varying(20)
31 );
32
33 --
34 -- language
35 --
36
37 CREATE SEQUENCE "language_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
38
39 CREATE TABLE "language" (
40         "id" integer DEFAULT nextval('language_id_seq') NOT NULL,
41   "name" character varying(40) NOT NULL,
42   "code" character varying(2) NOT NULL,
43   Constraint "language_pkey" Primary Key ("id")
44 );
45
46 --
47 -- comment_status
48 --
49
50 CREATE SEQUENCE "comment_status_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
51
52 CREATE TABLE "comment_status" (
53   "id" integer DEFAULT nextval('comment_status_id_seq') NOT NULL,
54   "name" character varying(40) NOT NULL,
55   CONSTRAINT "comment_status_pkey" PRIMARY KEY ("id")
56 );
57
58
59
60 --
61 -- rights
62 --
63
64 CREATE TABLE "rights" (
65         "id" integer NOT NULL,
66         "name" character varying(80) NOT NULL,
67         "description" text,
68         Constraint "rights_pkey" Primary Key ("id")
69 );
70
71 --
72 -- webdb_users
73 --
74
75 CREATE SEQUENCE "webdb_users_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
76
77 CREATE TABLE "webdb_users" (
78         "id" integer DEFAULT nextval('webdb_users_id_seq'::text) NOT NULL,
79         "login" character varying(16) UNIQUE NOT NULL,
80         "password" character varying(255) NOT NULL,
81         "is_admin" boolean DEFAULT '0' NOT NULL,
82         "comment" text,
83         Constraint "webdb_users_pkey" Primary Key ("id")
84 );
85
86
87 --
88 -- article type
89 --
90
91 CREATE SEQUENCE "article_type_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
92
93 CREATE TABLE "article_type" (
94         "id" integer DEFAULT nextval('article_type_id_seq') NOT NULL,
95         "name" character varying(40) NOT NULL,
96         CONSTRAINT "article_type_pkey" PRIMARY KEY ("id")
97 );
98
99 --
100 -- topic
101 --
102
103 CREATE SEQUENCE "topic_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
104
105 CREATE TABLE "topic" (
106         "id" integer DEFAULT nextval('topic_id_seq'::text) NOT NULL,
107         "parent_id" integer DEFAULT '0' NOT NULL,
108         "title" character varying(80) NOT NULL,
109         "description" text,
110         "filename" character varying(20) NOT NULL,
111         "main_url" character varying(255),
112         "archiv_url" character varying(255),
113         Constraint "topic_pkey" Primary Key ("id")
114 );
115
116 CREATE        INDEX "idx_topic_title" on "topic"           using btree ( "title" "varchar_ops" );
117
118
119 -- 
120 -- content_x_topics
121 --
122
123 CREATE TABLE "content_x_topic" (
124         "content_id" integer NOT NULL,
125         "topic_id" integer NOT NULL
126 );
127
128 CREATE UNIQUE INDEX "idx_content"     on "content_x_topic" using btree ( "content_id" "int4_ops", "topic_id" "int4_ops" );
129 CREATE UNIQUE INDEX "idx_topic"       on "content_x_topic" using btree ( "topic_id" "int4_ops", "content_id" "int4_ops" );
130
131 --
132 -- comment
133 --
134
135 CREATE SEQUENCE "comment_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
136 CREATE TABLE "comment" (
137   "id" integer DEFAULT nextval('comment_id_seq'::text) NOT NULL,
138   "title" character varying(80) NOT NULL,
139   "creator" character varying(80) NOT NULL,
140   "description" text NOT NULL,
141   "main_url" character varying(255),
142   "email" character varying(80),
143   "address" character varying(80),
144   "phone" character varying(20),
145   "webdb_create" timestamp with time zone NOT NULL,
146   "webdb_lastchange" timestamp with time zone,
147   "is_published" boolean DEFAULT '1' NOT NULL,
148   "to_language" integer DEFAULT '0' NOT NULL,
149   "to_media" integer NOT NULL,
150   "to_comment_status" smallint,
151   "checksum" integer,
152   "is_html" boolean DEFAULT '0' NOT NULL,
153   Constraint "comment_pkey" Primary Key ("id")
154 );
155
156 CREATE        INDEX "comment_checksum_index" on "comment" using btree ( "checksum" "int4_ops" );
157 CREATE        INDEX "idx_comment_to_media" on "comment" using btree ( "to_media" "int4_ops" );
158 CREATE        INDEX idx_comment_webdb_create on comment(webdb_create);
159 CREATE        INDEX "idx_comment_tomedia_ispublished" on "comment" using btree ( "to_media" "int4_ops", "is_published" "bool_ops" );
160
161
162
163       CREATE TABLE "comment_x_media" (
164          "comment_id" integer,
165          "media_id" integer
166       );
167       
168       CREATE UNIQUE INDEX idx_comment_media on comment_x_media (comment_id, media_id);
169       CREATE UNIQUE INDEX idx_media_comment on comment_x_media (media_id, comment_id);
170
171
172 --
173 -- media
174 --
175
176 CREATE SEQUENCE "media_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
177 CREATE TABLE "media" (
178         "id" integer DEFAULT nextval('media_id_seq'::text) NOT NULL,
179         "title" character varying(255),
180         "subtitle" character varying(255),
181         "edittitle" character varying(255),
182         "date" character(8) NOT NULL,
183         "creator" character varying(80),
184         "creator_main_url" character varying(255),
185         "creator_email" character varying(80),
186         "creator_address" character varying(80),
187         "creator_phone" character varying(20),
188         "description" text,
189         "comment" text,
190         "source" character varying(255),
191         "publish_date" timestamp with time zone,
192         "publish_server" character varying(255),
193         "publish_path" character varying(255),
194         "is_published" boolean DEFAULT '0' NOT NULL,
195         "is_produced" boolean DEFAULT '0' NOT NULL,
196         "to_feature" integer DEFAULT '0' NOT NULL,
197         "to_media_folder" integer DEFAULT '0' NOT NULL,
198         "to_media_type" smallint DEFAULT '0' NOT NULL,
199         "to_publisher" integer NOT NULL,
200         "to_language" integer DEFAULT '0',
201         "to_rights" integer DEFAULT '0',
202         "webdb_create" timestamp with time zone NOT NULL,
203         "webdb_lastchange" timestamp with time zone,
204         "to_media" integer
205 );
206
207 --
208 -- uploaded_media
209 --
210
211 CREATE TABLE "uploaded_media" (
212         "icon_is_produced" boolean DEFAULT '0' NOT NULL,
213         "icon_path" character varying(255),
214         "size" integer
215 )
216 INHERITS ("media");
217
218 CREATE UNIQUE INDEX "idx_uploaded_media_id" on "uploaded_media" using btree ( "id" "int4_ops" );
219 CREATE UNIQUE INDEX "idx_uploaded_media_is_published" on "uploaded_media" using btree ( "id" "int4_ops", "is_published" "bool_ops" );
220
221 --
222 -- images
223 --
224
225 CREATE TABLE "images" (
226         "image_data" oid,
227         "icon_data" oid,
228         "year" character varying(40),
229         "img_width" smallint,
230         "img_height" smallint,
231         "to_img_format" smallint DEFAULT '0' NOT NULL,
232         "to_img_layout" smallint DEFAULT '0' NOT NULL,
233         "to_img_type" smallint DEFAULT '0' NOT NULL,
234         "to_img_color" smallint DEFAULT '0' NOT NULL,
235         "icon_width" smallint,
236         "icon_height" smallint
237 )
238 INHERITS ("uploaded_media");
239
240 CREATE        INDEX "idx_images_is_published__icon_i" on "images" using btree ( "is_published" "bool_ops", "icon_is_produced" "bool_ops" );
241 CREATE UNIQUE INDEX "idx_images_id" on "images" using btree ( "id" "int4_ops" );
242
243         --
244         -- img_format
245         --
246         
247         CREATE TABLE "img_format" (
248           "id" smallint NOT NULL,
249           "name" character varying(20) NOT NULL,
250           "extension" character varying(10) NOT NULL,
251           "mimetype" character varying(40) NOT NULL,
252           "commment" character varying(255)
253         );
254         
255         --
256         -- img_layout
257         --
258         
259         CREATE TABLE "img_layout" (
260           "id" smallint NOT NULL,
261           "name" character varying(20) NOT NULL
262         );
263         
264         --
265         -- img_type
266         --
267         
268         CREATE TABLE "img_type" (
269           "id" smallint NOT NULL,
270           "name" character varying(30) NOT NULL
271         );
272         
273         --
274         -- img_color
275         --
276         
277         CREATE TABLE "img_color" (
278           "id" smallint NOT NULL,
279           "name" character varying(30) NOT NULL
280         );
281
282         
283 --
284 -- audio
285 --
286
287 CREATE TABLE "audio" (
288   "kbits" smallint
289 )
290 INHERITS ("uploaded_media");
291
292 CREATE        INDEX "idx_audio_is_published_produced" on "audio" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
293 CREATE UNIQUE INDEX "idx_audio_id" on "audio" using btree ( "id" "int4_ops" );
294
295 --
296 -- video
297 --
298
299 CREATE TABLE "video" (
300 )
301 INHERITS ("uploaded_media");
302
303 CREATE        INDEX "idx_video_is_published_produced" on "video" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
304 CREATE UNIQUE INDEX "idx_video_id" on "video" using btree ( "id" "int4_ops" );
305
306 --
307 -- other_media
308 --
309
310 CREATE TABLE "other_media" (
311 )
312 INHERITS ("uploaded_media");
313
314 CREATE        INDEX "idx_othermedia_is_published_produced" on "other_media" using btree ( "is_published" "bool_ops", "is_produced" "bool_ops" );
315 CREATE UNIQUE INDEX "idx_othermedia_id" on "other_media" using btree ( "id" "int4_ops" );
316
317 --
318 -- content
319 --
320
321 CREATE TABLE "content" (
322         "content_data" text,
323         "is_html" boolean DEFAULT '0' NOT NULL,
324         "to_article_type" smallint DEFAULT '0' NOT NULL,
325         "to_content" integer,
326         "checksum" integer
327 )
328 INHERITS ("media");
329
330 CREATE        INDEX "content_checksum_index" on "content" using btree ( "checksum" "int4_ops" );
331 CREATE        INDEX "idx_content_to_article_type" on "content" using btree ( "to_article_type" "int2_ops" );
332 CREATE        INDEX "idx_content_is_produced" on "content" using btree ( "is_produced" "bool_ops" );
333 CREATE        INDEX "idx_content_is_published__to_ar" on "content" using btree ( "is_published" "bool_ops", "to_article_type" "int2_ops" );
334 CREATE        INDEX "idx_content_is_published__id" on "content" using btree ( "is_published" "bool_ops", "id" "int4_ops" );
335 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" );
336 CREATE        INDEX "idx_content_is_published" on "content" using btree ( "is_published" "bool_ops" );
337 CREATE        INDEX idx_content_webdb_create on content(webdb_create);
338
339
340     -- content_x_media
341
342     CREATE TABLE "content_x_media" (
343       "content_id" integer,
344       "media_id" integer
345     );
346
347     CREATE UNIQUE INDEX "idx_cxm_content" on "content_x_media" using btree ( "content_id" "int4_ops" );
348     CREATE UNIQUE INDEX "idx_cxm_media" on "content_x_media" using btree ( "media_id" "int4_ops" );
349
350 --
351 -- breaking
352 --
353
354 CREATE SEQUENCE "breaking_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
355
356 CREATE TABLE "breaking" (
357   "id" integer DEFAULT nextval('breaking_id_seq'::text) NOT NULL,
358   "text" character varying(255) NOT NULL,
359   "webdb_create" timestamp with time zone NOT NULL
360 );
361
362 --
363 -- messages
364 --
365
366 CREATE SEQUENCE "messages_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
367
368 CREATE TABLE "messages" (
369   "id" integer DEFAULT nextval('messages_id_seq'::text) NOT NULL,
370   "title" character varying(30),
371   "description" character varying(255) NOT NULL,
372   "creator" character varying(30) NOT NULL,
373   "webdb_create" timestamp with time zone NOT NULL
374 );
375