Re add wpScrolltop id in EditPage
[lhc/web/wiklou.git] / maintenance / oracle / tables.sql
1 -- defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}';
2 define mw_prefix='{$wgDBprefix}';
3
4
5 CREATE SEQUENCE user_user_id_seq;
6 CREATE TABLE &mw_prefix.mwuser ( -- replace reserved word 'user'
7 user_id NUMBER NOT NULL,
8 user_name VARCHAR2(255) NOT NULL,
9 user_real_name VARCHAR2(512),
10 user_password VARCHAR2(255),
11 user_newpassword VARCHAR2(255),
12 user_newpass_time TIMESTAMP(6) WITH TIME ZONE,
13 user_token VARCHAR2(32),
14 user_email VARCHAR2(255),
15 user_email_token VARCHAR2(32),
16 user_email_token_expires TIMESTAMP(6) WITH TIME ZONE,
17 user_email_authenticated TIMESTAMP(6) WITH TIME ZONE,
18 user_options CLOB,
19 user_touched TIMESTAMP(6) WITH TIME ZONE,
20 user_registration TIMESTAMP(6) WITH TIME ZONE,
21 user_editcount NUMBER,
22 user_password_expires TIMESTAMP(6) WITH TIME ZONE
23 );
24 ALTER TABLE &mw_prefix.mwuser ADD CONSTRAINT &mw_prefix.mwuser_pk PRIMARY KEY (user_id);
25 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01 ON &mw_prefix.mwuser (user_name);
26 CREATE INDEX &mw_prefix.mwuser_i01 ON &mw_prefix.mwuser (user_email_token);
27 CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
28
29 -- Create a dummy user to satisfy fk contraints especially with revisions
30 INSERT INTO &mw_prefix.mwuser
31 (user_id, user_name, user_options, user_touched, user_registration, user_editcount)
32 VALUES (0,'Anonymous','', current_timestamp, current_timestamp,0);
33
34 CREATE TABLE &mw_prefix.user_groups (
35 ug_user NUMBER DEFAULT 0 NOT NULL,
36 ug_group VARCHAR2(255) NOT NULL,
37 ug_expiry TIMESTAMP(6) WITH TIME ZONE NULL
38 );
39 ALTER TABLE &mw_prefix.user_groups ADD CONSTRAINT &mw_prefix.user_groups_pk PRIMARY KEY (ug_user,ug_group);
40 ALTER TABLE &mw_prefix.user_groups ADD CONSTRAINT &mw_prefix.user_groups_fk1 FOREIGN KEY (ug_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
41 CREATE INDEX &mw_prefix.user_groups_i01 ON &mw_prefix.user_groups (ug_group);
42 CREATE INDEX &mw_prefix.user_groups_i02 ON &mw_prefix.user_groups (ug_expiry);
43
44 CREATE TABLE &mw_prefix.user_former_groups (
45 ufg_user NUMBER DEFAULT 0 NOT NULL,
46 ufg_group VARCHAR2(255) NOT NULL
47 );
48 ALTER TABLE &mw_prefix.user_former_groups ADD CONSTRAINT &mw_prefix.user_former_groups_fk1 FOREIGN KEY (ufg_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
49 CREATE UNIQUE INDEX &mw_prefix.user_former_groups_u01 ON &mw_prefix.user_former_groups (ufg_user,ufg_group);
50
51 CREATE TABLE &mw_prefix.user_newtalk (
52 user_id NUMBER DEFAULT 0 NOT NULL,
53 user_ip VARCHAR2(40) NULL,
54 user_last_timestamp TIMESTAMP(6) WITH TIME ZONE
55 );
56 ALTER TABLE &mw_prefix.user_newtalk ADD CONSTRAINT &mw_prefix.user_newtalk_fk1 FOREIGN KEY (user_id) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
57 CREATE INDEX &mw_prefix.user_newtalk_i01 ON &mw_prefix.user_newtalk (user_id);
58 CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip);
59
60 CREATE TABLE &mw_prefix.user_properties (
61 up_user NUMBER NOT NULL,
62 up_property VARCHAR2(255) NOT NULL,
63 up_value CLOB
64 );
65 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01 on &mw_prefix.user_properties (up_user,up_property);
66 CREATE INDEX &mw_prefix.user_properties_i01 on &mw_prefix.user_properties (up_property);
67
68 CREATE SEQUENCE page_page_id_seq;
69 CREATE TABLE &mw_prefix.page (
70 page_id NUMBER NOT NULL,
71 page_namespace NUMBER DEFAULT 0 NOT NULL,
72 page_title VARCHAR2(255) NOT NULL,
73 page_restrictions VARCHAR2(255),
74 page_is_redirect CHAR(1) DEFAULT '0' NOT NULL,
75 page_is_new CHAR(1) DEFAULT '0' NOT NULL,
76 page_random NUMBER(15,14) NOT NULL,
77 page_touched TIMESTAMP(6) WITH TIME ZONE,
78 page_links_updated TIMESTAMP(6) WITH TIME ZONE,
79 page_latest NUMBER DEFAULT 0 NOT NULL, -- FK?
80 page_len NUMBER DEFAULT 0 NOT NULL,
81 page_content_model VARCHAR2(32),
82 page_lang VARCHAR2(35) DEFAULT NULL
83 );
84 ALTER TABLE &mw_prefix.page ADD CONSTRAINT &mw_prefix.page_pk PRIMARY KEY (page_id);
85 CREATE UNIQUE INDEX &mw_prefix.page_u01 ON &mw_prefix.page (page_namespace,page_title);
86 CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random);
87 CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len);
88 CREATE INDEX &mw_prefix.page_i03 ON &mw_prefix.page (page_is_redirect, page_namespace, page_len);
89
90 -- Create a dummy page to satisfy fk contraints especially with revisions
91 INSERT INTO &mw_prefix.page
92 VALUES (0, 0, ' ', NULL, 0, 0, 0, current_timestamp, NULL, 0, 0, NULL, NULL);
93
94 /*$mw$*/
95 CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page
96 FOR EACH ROW WHEN (new.page_random IS NULL)
97 BEGIN
98 SELECT dbms_random.value INTO :NEW.page_random FROM dual;
99 END;
100 /*$mw$*/
101
102 CREATE SEQUENCE revision_rev_id_seq;
103 CREATE TABLE &mw_prefix.revision (
104 rev_id NUMBER NOT NULL,
105 rev_page NUMBER NOT NULL,
106 rev_text_id NUMBER NULL,
107 rev_comment VARCHAR2(255),
108 rev_user NUMBER DEFAULT 0 NOT NULL,
109 rev_user_text VARCHAR2(255) NOT NULL,
110 rev_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
111 rev_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
112 rev_deleted CHAR(1) DEFAULT '0' NOT NULL,
113 rev_len NUMBER NULL,
114 rev_parent_id NUMBER DEFAULT NULL,
115 rev_sha1 VARCHAR2(32) NULL,
116 rev_content_model VARCHAR2(32),
117 rev_content_format VARCHAR2(64)
118 );
119 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_pk PRIMARY KEY (rev_id);
120 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk1 FOREIGN KEY (rev_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
121 ALTER TABLE &mw_prefix.revision ADD CONSTRAINT &mw_prefix.revision_fk2 FOREIGN KEY (rev_user) REFERENCES &mw_prefix.mwuser(user_id) DEFERRABLE INITIALLY DEFERRED;
122 CREATE UNIQUE INDEX &mw_prefix.revision_u01 ON &mw_prefix.revision (rev_page, rev_id);
123 CREATE INDEX &mw_prefix.revision_i01 ON &mw_prefix.revision (rev_timestamp);
124 CREATE INDEX &mw_prefix.revision_i02 ON &mw_prefix.revision (rev_page,rev_timestamp);
125 CREATE INDEX &mw_prefix.revision_i03 ON &mw_prefix.revision (rev_user,rev_timestamp);
126 CREATE INDEX &mw_prefix.revision_i04 ON &mw_prefix.revision (rev_user_text,rev_timestamp);
127 CREATE INDEX &mw_prefix.revision_i05 ON &mw_prefix.revision (rev_page,rev_user,rev_timestamp);
128
129 CREATE SEQUENCE text_old_id_seq;
130 CREATE TABLE &mw_prefix.pagecontent ( -- replaces reserved word 'text'
131 old_id NUMBER NOT NULL,
132 old_text CLOB,
133 old_flags VARCHAR2(255)
134 );
135 ALTER TABLE &mw_prefix.pagecontent ADD CONSTRAINT &mw_prefix.pagecontent_pk PRIMARY KEY (old_id);
136
137 CREATE SEQUENCE archive_ar_id_seq;
138 CREATE TABLE &mw_prefix.archive (
139 ar_id NUMBER NOT NULL,
140 ar_namespace NUMBER DEFAULT 0 NOT NULL,
141 ar_title VARCHAR2(255) NOT NULL,
142 ar_text CLOB,
143 ar_comment VARCHAR2(255),
144 ar_user NUMBER DEFAULT 0 NOT NULL,
145 ar_user_text VARCHAR2(255) NOT NULL,
146 ar_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
147 ar_minor_edit CHAR(1) DEFAULT '0' NOT NULL,
148 ar_flags VARCHAR2(255),
149 ar_rev_id NUMBER,
150 ar_text_id NUMBER,
151 ar_deleted CHAR(1) DEFAULT '0' NOT NULL,
152 ar_len NUMBER,
153 ar_page_id NUMBER,
154 ar_parent_id NUMBER,
155 ar_sha1 VARCHAR2(32),
156 ar_content_model VARCHAR2(32),
157 ar_content_format VARCHAR2(64)
158 );
159 ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_pk PRIMARY KEY (ar_id);
160 ALTER TABLE &mw_prefix.archive ADD CONSTRAINT &mw_prefix.archive_fk1 FOREIGN KEY (ar_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
161 CREATE INDEX &mw_prefix.archive_i01 ON &mw_prefix.archive (ar_namespace,ar_title,ar_timestamp);
162 CREATE INDEX &mw_prefix.archive_i02 ON &mw_prefix.archive (ar_user_text,ar_timestamp);
163 CREATE INDEX &mw_prefix.archive_i03 ON &mw_prefix.archive (ar_rev_id);
164
165 CREATE TABLE &mw_prefix.pagelinks (
166 pl_from NUMBER NOT NULL,
167 pl_namespace NUMBER DEFAULT 0 NOT NULL,
168 pl_title VARCHAR2(255) NOT NULL
169 );
170 ALTER TABLE &mw_prefix.pagelinks ADD CONSTRAINT &mw_prefix.pagelinks_fk1 FOREIGN KEY (pl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
171 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u01 ON &mw_prefix.pagelinks (pl_from,pl_namespace,pl_title);
172 CREATE UNIQUE INDEX &mw_prefix.pagelinks_u02 ON &mw_prefix.pagelinks (pl_namespace,pl_title,pl_from);
173
174 CREATE TABLE &mw_prefix.templatelinks (
175 tl_from NUMBER NOT NULL,
176 tl_namespace NUMBER DEFAULT 0 NOT NULL,
177 tl_title VARCHAR2(255) NOT NULL
178 );
179 ALTER TABLE &mw_prefix.templatelinks ADD CONSTRAINT &mw_prefix.templatelinks_fk1 FOREIGN KEY (tl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
180 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u01 ON &mw_prefix.templatelinks (tl_from,tl_namespace,tl_title);
181 CREATE UNIQUE INDEX &mw_prefix.templatelinks_u02 ON &mw_prefix.templatelinks (tl_namespace,tl_title,tl_from);
182
183 CREATE TABLE &mw_prefix.imagelinks (
184 il_from NUMBER NOT NULL,
185 il_to VARCHAR2(255) NOT NULL
186 );
187 ALTER TABLE &mw_prefix.imagelinks ADD CONSTRAINT &mw_prefix.imagelinks_fk1 FOREIGN KEY (il_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
188 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u01 ON &mw_prefix.imagelinks (il_from,il_to);
189 CREATE UNIQUE INDEX &mw_prefix.imagelinks_u02 ON &mw_prefix.imagelinks (il_to,il_from);
190
191
192 CREATE TABLE &mw_prefix.categorylinks (
193 cl_from NUMBER NOT NULL,
194 cl_to VARCHAR2(255) NOT NULL,
195 cl_sortkey VARCHAR2(230),
196 cl_sortkey_prefix VARCHAR2(255),
197 cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
198 cl_collation VARCHAR2(32),
199 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
200 );
201 ALTER TABLE &mw_prefix.categorylinks ADD CONSTRAINT &mw_prefix.categorylinks_fk1 FOREIGN KEY (cl_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
202 CREATE UNIQUE INDEX &mw_prefix.categorylinks_u01 ON &mw_prefix.categorylinks (cl_from,cl_to);
203 CREATE INDEX &mw_prefix.categorylinks_i01 ON &mw_prefix.categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
204 CREATE INDEX &mw_prefix.categorylinks_i02 ON &mw_prefix.categorylinks (cl_to,cl_timestamp);
205 CREATE INDEX &mw_prefix.categorylinks_i03 ON &mw_prefix.categorylinks (cl_collation);
206
207 CREATE SEQUENCE category_cat_id_seq;
208 CREATE TABLE &mw_prefix.category (
209 cat_id NUMBER NOT NULL,
210 cat_title VARCHAR2(255) NOT NULL,
211 cat_pages NUMBER DEFAULT 0 NOT NULL,
212 cat_subcats NUMBER DEFAULT 0 NOT NULL,
213 cat_files NUMBER DEFAULT 0 NOT NULL
214 );
215 ALTER TABLE &mw_prefix.category ADD CONSTRAINT &mw_prefix.category_pk PRIMARY KEY (cat_id);
216 CREATE UNIQUE INDEX &mw_prefix.category_u01 ON &mw_prefix.category (cat_title);
217 CREATE INDEX &mw_prefix.category_i01 ON &mw_prefix.category (cat_pages);
218
219 CREATE SEQUENCE externallinks_el_id_seq;
220 CREATE TABLE &mw_prefix.externallinks (
221 el_id NUMBER NOT NULL,
222 el_from NUMBER NOT NULL,
223 el_to VARCHAR2(2048) NOT NULL,
224 el_index VARCHAR2(2048) NOT NULL,
225 el_index_60 VARBINARY(60) NOT NULL DEFAULT ''
226 );
227 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_pk PRIMARY KEY (el_id);
228 ALTER TABLE &mw_prefix.externallinks ADD CONSTRAINT &mw_prefix.externallinks_fk1 FOREIGN KEY (el_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
229 CREATE INDEX &mw_prefix.externallinks_i01 ON &mw_prefix.externallinks (el_from, el_to);
230 CREATE INDEX &mw_prefix.externallinks_i02 ON &mw_prefix.externallinks (el_to, el_from);
231 CREATE INDEX &mw_prefix.externallinks_i03 ON &mw_prefix.externallinks (el_index);
232 CREATE INDEX &mw_prefix.externallinks_i04 ON &mw_prefix.externallinks (el_index_60, el_id);
233 CREATE INDEX &mw_prefix.externallinks_i05 ON &mw_prefix.externallinks (el_from, el_index_60, el_id);
234
235 CREATE TABLE &mw_prefix.langlinks (
236 ll_from NUMBER NOT NULL,
237 ll_lang VARCHAR2(20),
238 ll_title VARCHAR2(255)
239 );
240 ALTER TABLE &mw_prefix.langlinks ADD CONSTRAINT &mw_prefix.langlinks_fk1 FOREIGN KEY (ll_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
241 CREATE UNIQUE INDEX &mw_prefix.langlinks_u01 ON &mw_prefix.langlinks (ll_from, ll_lang);
242 CREATE INDEX &mw_prefix.langlinks_i01 ON &mw_prefix.langlinks (ll_lang, ll_title);
243
244 CREATE TABLE &mw_prefix.iwlinks (
245 iwl_from NUMBER DEFAULT 0 NOT NULL,
246 iwl_prefix VARCHAR2(20),
247 iwl_title VARCHAR2(255)
248 );
249 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
250 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
251
252 CREATE TABLE &mw_prefix.site_stats (
253 ss_row_id NUMBER NOT NULL ,
254 ss_total_edits NUMBER DEFAULT 0,
255 ss_good_articles NUMBER DEFAULT 0,
256 ss_total_pages NUMBER DEFAULT -1,
257 ss_users NUMBER DEFAULT -1,
258 ss_active_users NUMBER DEFAULT -1,
259 ss_images NUMBER DEFAULT 0
260 );
261 CREATE UNIQUE INDEX &mw_prefix.site_stats_u01 ON &mw_prefix.site_stats (ss_row_id);
262
263 CREATE SEQUENCE ipblocks_ipb_id_seq;
264 CREATE TABLE &mw_prefix.ipblocks (
265 ipb_id NUMBER NOT NULL,
266 ipb_address VARCHAR2(255) NULL,
267 ipb_user NUMBER DEFAULT 0 NOT NULL,
268 ipb_by NUMBER DEFAULT 0 NOT NULL,
269 ipb_by_text VARCHAR2(255) NULL,
270 ipb_reason VARCHAR2(255) NOT NULL,
271 ipb_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
272 ipb_auto CHAR(1) DEFAULT '0' NOT NULL,
273 ipb_anon_only CHAR(1) DEFAULT '0' NOT NULL,
274 ipb_create_account CHAR(1) DEFAULT '1' NOT NULL,
275 ipb_enable_autoblock CHAR(1) DEFAULT '1' NOT NULL,
276 ipb_expiry TIMESTAMP(6) WITH TIME ZONE NOT NULL,
277 ipb_range_start VARCHAR2(255),
278 ipb_range_end VARCHAR2(255),
279 ipb_deleted CHAR(1) DEFAULT '0' NOT NULL,
280 ipb_block_email CHAR(1) DEFAULT '0' NOT NULL,
281 ipb_allow_usertalk CHAR(1) DEFAULT '0' NOT NULL,
282 ipb_parent_block_id NUMBER DEFAULT NULL
283 );
284 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_pk PRIMARY KEY (ipb_id);
285 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk1 FOREIGN KEY (ipb_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
286 ALTER TABLE &mw_prefix.ipblocks ADD CONSTRAINT &mw_prefix.ipblocks_fk2 FOREIGN KEY (ipb_by) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
287 CREATE UNIQUE INDEX &mw_prefix.ipblocks_u01 ON &mw_prefix.ipblocks (ipb_address, ipb_user, ipb_auto, ipb_anon_only);
288 CREATE INDEX &mw_prefix.ipblocks_i01 ON &mw_prefix.ipblocks (ipb_user);
289 CREATE INDEX &mw_prefix.ipblocks_i02 ON &mw_prefix.ipblocks (ipb_range_start, ipb_range_end);
290 CREATE INDEX &mw_prefix.ipblocks_i03 ON &mw_prefix.ipblocks (ipb_timestamp);
291 CREATE INDEX &mw_prefix.ipblocks_i04 ON &mw_prefix.ipblocks (ipb_expiry);
292 CREATE INDEX &mw_prefix.ipblocks_i05 ON &mw_prefix.ipblocks (ipb_parent_block_id);
293
294 CREATE TABLE &mw_prefix.image (
295 img_name VARCHAR2(255) NOT NULL,
296 img_size NUMBER DEFAULT 0 NOT NULL,
297 img_width NUMBER DEFAULT 0 NOT NULL,
298 img_height NUMBER DEFAULT 0 NOT NULL,
299 img_metadata CLOB,
300 img_bits NUMBER DEFAULT 0 NOT NULL,
301 img_media_type VARCHAR2(32),
302 img_major_mime VARCHAR2(32) DEFAULT 'unknown',
303 img_minor_mime VARCHAR2(100) DEFAULT 'unknown',
304 img_description VARCHAR2(255),
305 img_user NUMBER DEFAULT 0 NOT NULL,
306 img_user_text VARCHAR2(255) NOT NULL,
307 img_timestamp TIMESTAMP(6) WITH TIME ZONE,
308 img_sha1 VARCHAR2(32)
309 );
310 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_pk PRIMARY KEY (img_name);
311 ALTER TABLE &mw_prefix.image ADD CONSTRAINT &mw_prefix.image_fk1 FOREIGN KEY (img_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
312 CREATE INDEX &mw_prefix.image_i01 ON &mw_prefix.image (img_user_text,img_timestamp);
313 CREATE INDEX &mw_prefix.image_i02 ON &mw_prefix.image (img_size);
314 CREATE INDEX &mw_prefix.image_i03 ON &mw_prefix.image (img_timestamp);
315 CREATE INDEX &mw_prefix.image_i04 ON &mw_prefix.image (img_sha1);
316
317
318 CREATE TABLE &mw_prefix.oldimage (
319 oi_name VARCHAR2(255) DEFAULT 0 NOT NULL,
320 oi_archive_name VARCHAR2(255),
321 oi_size NUMBER DEFAULT 0 NOT NULL,
322 oi_width NUMBER DEFAULT 0 NOT NULL,
323 oi_height NUMBER DEFAULT 0 NOT NULL,
324 oi_bits NUMBER DEFAULT 0 NOT NULL,
325 oi_description VARCHAR2(255),
326 oi_user NUMBER DEFAULT 0 NOT NULL,
327 oi_user_text VARCHAR2(255) NOT NULL,
328 oi_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
329 oi_metadata CLOB,
330 oi_media_type VARCHAR2(32) DEFAULT NULL,
331 oi_major_mime VARCHAR2(32) DEFAULT 'unknown',
332 oi_minor_mime VARCHAR2(100) DEFAULT 'unknown',
333 oi_deleted NUMBER DEFAULT 0 NOT NULL,
334 oi_sha1 VARCHAR2(32)
335 );
336 ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk1 FOREIGN KEY (oi_name) REFERENCES &mw_prefix.image(img_name) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
337 ALTER TABLE &mw_prefix.oldimage ADD CONSTRAINT &mw_prefix.oldimage_fk2 FOREIGN KEY (oi_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
338 CREATE INDEX &mw_prefix.oldimage_i01 ON &mw_prefix.oldimage (oi_user_text,oi_timestamp);
339 CREATE INDEX &mw_prefix.oldimage_i02 ON &mw_prefix.oldimage (oi_name,oi_timestamp);
340 CREATE INDEX &mw_prefix.oldimage_i03 ON &mw_prefix.oldimage (oi_name,oi_archive_name);
341 CREATE INDEX &mw_prefix.oldimage_i04 ON &mw_prefix.oldimage (oi_sha1);
342
343
344 CREATE SEQUENCE filearchive_fa_id_seq;
345 CREATE TABLE &mw_prefix.filearchive (
346 fa_id NUMBER NOT NULL,
347 fa_name VARCHAR2(255) NOT NULL,
348 fa_archive_name VARCHAR2(255),
349 fa_storage_group VARCHAR2(16),
350 fa_storage_key VARCHAR2(64),
351 fa_deleted_user NUMBER DEFAULT 0 NOT NULL,
352 fa_deleted_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
353 fa_deleted_reason CLOB,
354 fa_size NUMBER DEFAULT 0 NOT NULL,
355 fa_width NUMBER DEFAULT 0 NOT NULL,
356 fa_height NUMBER DEFAULT 0 NOT NULL,
357 fa_metadata CLOB,
358 fa_bits NUMBER DEFAULT 0 NOT NULL,
359 fa_media_type VARCHAR2(32) DEFAULT NULL,
360 fa_major_mime VARCHAR2(32) DEFAULT 'unknown',
361 fa_minor_mime VARCHAR2(100) DEFAULT 'unknown',
362 fa_description VARCHAR2(255),
363 fa_user NUMBER DEFAULT 0 NOT NULL,
364 fa_user_text VARCHAR2(255) NOT NULL,
365 fa_timestamp TIMESTAMP(6) WITH TIME ZONE,
366 fa_deleted NUMBER DEFAULT 0 NOT NULL,
367 fa_sha1 VARCHAR2(32)
368 );
369 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_pk PRIMARY KEY (fa_id);
370 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk1 FOREIGN KEY (fa_deleted_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
371 ALTER TABLE &mw_prefix.filearchive ADD CONSTRAINT &mw_prefix.filearchive_fk2 FOREIGN KEY (fa_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
372 CREATE INDEX &mw_prefix.filearchive_i01 ON &mw_prefix.filearchive (fa_name, fa_timestamp);
373 CREATE INDEX &mw_prefix.filearchive_i02 ON &mw_prefix.filearchive (fa_storage_group, fa_storage_key);
374 CREATE INDEX &mw_prefix.filearchive_i03 ON &mw_prefix.filearchive (fa_deleted_timestamp);
375 CREATE INDEX &mw_prefix.filearchive_i04 ON &mw_prefix.filearchive (fa_user_text,fa_timestamp);
376 CREATE INDEX &mw_prefix.filearchive_i05 ON &mw_prefix.filearchive (fa_sha1);
377
378 CREATE SEQUENCE uploadstash_us_id_seq;
379 CREATE TABLE &mw_prefix.uploadstash (
380 us_id NUMBER NOT NULL,
381 us_user NUMBER DEFAULT 0 NOT NULL,
382 us_key VARCHAR2(255) NOT NULL,
383 us_orig_path VARCHAR2(255) NOT NULL,
384 us_path VARCHAR2(255) NOT NULL,
385 us_source_type VARCHAR2(50),
386 us_timestamp TIMESTAMP(6) WITH TIME ZONE,
387 us_status VARCHAR2(50) NOT NULL,
388 us_chunk_inx NUMBER,
389 us_size NUMBER NOT NULL,
390 us_sha1 VARCHAR2(32) NOT NULL,
391 us_mime VARCHAR2(255),
392 us_media_type VARCHAR2(32) DEFAULT NULL,
393 us_image_width NUMBER,
394 us_image_height NUMBER,
395 us_image_bits NUMBER,
396 us_props BLOB
397 );
398 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_pk PRIMARY KEY (us_id);
399 ALTER TABLE &mw_prefix.uploadstash ADD CONSTRAINT &mw_prefix.uploadstash_fk1 FOREIGN KEY (us_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
400 CREATE INDEX &mw_prefix.uploadstash_i01 ON &mw_prefix.uploadstash (us_user);
401 CREATE INDEX &mw_prefix.uploadstash_i02 ON &mw_prefix.uploadstash (us_timestamp);
402 CREATE UNIQUE INDEX &mw_prefix.uploadstash_u01 ON &mw_prefix.uploadstash (us_key);
403
404 CREATE SEQUENCE recentchanges_rc_id_seq;
405 CREATE TABLE &mw_prefix.recentchanges (
406 rc_id NUMBER NOT NULL,
407 rc_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
408 rc_cur_time TIMESTAMP(6) WITH TIME ZONE,
409 rc_user NUMBER DEFAULT 0 NOT NULL,
410 rc_user_text VARCHAR2(255) NOT NULL,
411 rc_namespace NUMBER DEFAULT 0 NOT NULL,
412 rc_title VARCHAR2(255) NOT NULL,
413 rc_comment VARCHAR2(255),
414 rc_minor CHAR(1) DEFAULT '0' NOT NULL,
415 rc_bot CHAR(1) DEFAULT '0' NOT NULL,
416 rc_new CHAR(1) DEFAULT '0' NOT NULL,
417 rc_cur_id NUMBER DEFAULT 0 NOT NULL,
418 rc_this_oldid NUMBER DEFAULT 0 NOT NULL,
419 rc_last_oldid NUMBER DEFAULT 0 NOT NULL,
420 rc_type CHAR(1) DEFAULT '0' NOT NULL,
421 rc_source VARCHAR2(16),
422 rc_patrolled CHAR(1) DEFAULT '0' NOT NULL,
423 rc_ip VARCHAR2(15),
424 rc_old_len NUMBER,
425 rc_new_len NUMBER,
426 rc_deleted CHAR(1) DEFAULT '0' NOT NULL,
427 rc_logid NUMBER DEFAULT 0 NOT NULL,
428 rc_log_type VARCHAR2(255),
429 rc_log_action VARCHAR2(255),
430 rc_params CLOB
431 );
432 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_pk PRIMARY KEY (rc_id);
433 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk1 FOREIGN KEY (rc_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
434 ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
435 CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
436 CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
437 CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
438 CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
439 CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
440 CREATE INDEX &mw_prefix.recentchanges_i06 ON &mw_prefix.recentchanges (rc_namespace, rc_user_text);
441 CREATE INDEX &mw_prefix.recentchanges_i07 ON &mw_prefix.recentchanges (rc_user_text, rc_timestamp);
442 CREATE INDEX &mw_prefix.recentchanges_i08 ON &mw_prefix.recentchanges (rc_namespace, rc_type, rc_patrolled, rc_timestamp);
443
444 CREATE TABLE &mw_prefix.watchlist (
445 wl_id NUMBER NOT NULL,
446 wl_user NUMBER NOT NULL,
447 wl_namespace NUMBER DEFAULT 0 NOT NULL,
448 wl_title VARCHAR2(255) NOT NULL,
449 wl_notificationtimestamp TIMESTAMP(6) WITH TIME ZONE
450 );
451 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_pk PRIMARY KEY (wl_id);
452 ALTER TABLE &mw_prefix.watchlist ADD CONSTRAINT &mw_prefix.watchlist_fk1 FOREIGN KEY (wl_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
453 CREATE UNIQUE INDEX &mw_prefix.watchlist_u01 ON &mw_prefix.watchlist (wl_user, wl_namespace, wl_title);
454 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
455
456
457 CREATE TABLE &mw_prefix.searchindex (
458 si_page NUMBER NOT NULL,
459 si_title VARCHAR2(255),
460 si_text CLOB NOT NULL
461 );
462 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
463
464 CREATE TABLE &mw_prefix.interwiki (
465 iw_prefix VARCHAR2(32) NOT NULL,
466 iw_url VARCHAR2(127) NOT NULL,
467 iw_api BLOB NOT NULL,
468 iw_wikiid VARCHAR2(64),
469 iw_local CHAR(1) NOT NULL,
470 iw_trans CHAR(1) DEFAULT '0' NOT NULL
471 );
472 CREATE UNIQUE INDEX &mw_prefix.interwiki_u01 ON &mw_prefix.interwiki (iw_prefix);
473
474 CREATE TABLE &mw_prefix.querycache (
475 qc_type VARCHAR2(32) NOT NULL,
476 qc_value NUMBER DEFAULT 0 NOT NULL,
477 qc_namespace NUMBER DEFAULT 0 NOT NULL,
478 qc_title VARCHAR2(255) NOT NULL
479 );
480 CREATE INDEX &mw_prefix.querycache_u01 ON &mw_prefix.querycache (qc_type,qc_value);
481
482 CREATE TABLE &mw_prefix.objectcache (
483 keyname VARCHAR2(255) ,
484 value BLOB,
485 exptime TIMESTAMP(6) WITH TIME ZONE NOT NULL
486 );
487 CREATE INDEX &mw_prefix.objectcache_i01 ON &mw_prefix.objectcache (exptime);
488
489 CREATE TABLE &mw_prefix.transcache (
490 tc_url VARCHAR2(255) NOT NULL,
491 tc_contents CLOB NOT NULL,
492 tc_time TIMESTAMP(6) WITH TIME ZONE NOT NULL
493 );
494 CREATE UNIQUE INDEX &mw_prefix.transcache_u01 ON &mw_prefix.transcache (tc_url);
495
496
497 CREATE SEQUENCE logging_log_id_seq;
498 CREATE TABLE &mw_prefix.logging (
499 log_id NUMBER NOT NULL,
500 log_type VARCHAR2(10) NOT NULL,
501 log_action VARCHAR2(10) NOT NULL,
502 log_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
503 log_user NUMBER DEFAULT 0 NOT NULL,
504 log_user_text VARCHAR2(255),
505 log_namespace NUMBER DEFAULT 0 NOT NULL,
506 log_title VARCHAR2(255) NOT NULL,
507 log_page NUMBER,
508 log_comment VARCHAR2(255),
509 log_params CLOB,
510 log_deleted CHAR(1) DEFAULT '0' NOT NULL
511 );
512 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_pk PRIMARY KEY (log_id);
513 ALTER TABLE &mw_prefix.logging ADD CONSTRAINT &mw_prefix.logging_fk1 FOREIGN KEY (log_user) REFERENCES &mw_prefix.mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
514 CREATE INDEX &mw_prefix.logging_i01 ON &mw_prefix.logging (log_type, log_timestamp);
515 CREATE INDEX &mw_prefix.logging_i02 ON &mw_prefix.logging (log_user, log_timestamp);
516 CREATE INDEX &mw_prefix.logging_i03 ON &mw_prefix.logging (log_namespace, log_title, log_timestamp);
517 CREATE INDEX &mw_prefix.logging_i04 ON &mw_prefix.logging (log_timestamp);
518 CREATE INDEX &mw_prefix.logging_i05 ON &mw_prefix.logging (log_type, log_action, log_timestamp);
519 CREATE INDEX &mw_prefix.logging_i06 ON &mw_prefix.logging (log_user_text, log_type, log_timestamp);
520 CREATE INDEX &mw_prefix.logging_i07 ON &mw_prefix.logging (log_user_text, log_timestamp);
521
522 CREATE TABLE &mw_prefix.log_search (
523 ls_field VARCHAR2(32) NOT NULL,
524 ls_value VARCHAR2(255) NOT NULL,
525 ls_log_id NuMBER DEFAULT 0 NOT NULL
526 );
527 ALTER TABLE &mw_prefix.log_search ADD CONSTRAINT log_search_pk PRIMARY KEY (ls_field,ls_value,ls_log_id);
528 CREATE INDEX &mw_prefix.log_search_i01 ON &mw_prefix.log_search (ls_log_id);
529
530
531 CREATE SEQUENCE job_job_id_seq;
532 CREATE TABLE &mw_prefix.job (
533 job_id NUMBER NOT NULL,
534 job_cmd VARCHAR2(60) NOT NULL,
535 job_namespace NUMBER DEFAULT 0 NOT NULL,
536 job_title VARCHAR2(255) NOT NULL,
537 job_timestamp TIMESTAMP(6) WITH TIME ZONE NULL,
538 job_params CLOB NOT NULL,
539 job_random NUMBER DEFAULT 0 NOT NULL,
540 job_token VARCHAR2(32),
541 job_token_timestamp TIMESTAMP(6) WITH TIME ZONE,
542 job_sha1 VARCHAR2(32),
543 job_attempts NUMBER DEFAULT 0 NOT NULL
544 );
545 ALTER TABLE &mw_prefix.job ADD CONSTRAINT &mw_prefix.job_pk PRIMARY KEY (job_id);
546 CREATE INDEX &mw_prefix.job_i01 ON &mw_prefix.job (job_cmd, job_namespace, job_title);
547 CREATE INDEX &mw_prefix.job_i02 ON &mw_prefix.job (job_timestamp);
548 CREATE INDEX &mw_prefix.job_i03 ON &mw_prefix.job (job_sha1);
549 CREATE INDEX &mw_prefix.job_i04 ON &mw_prefix.job (job_cmd,job_token,job_random);
550 CREATE INDEX &mw_prefix.job_i05 ON &mw_prefix.job (job_attempts);
551
552 CREATE TABLE &mw_prefix.querycache_info (
553 qci_type VARCHAR2(32) NOT NULL,
554 qci_timestamp TIMESTAMP(6) WITH TIME ZONE NULL
555 );
556 CREATE UNIQUE INDEX &mw_prefix.querycache_info_u01 ON &mw_prefix.querycache_info (qci_type);
557
558 CREATE TABLE &mw_prefix.redirect (
559 rd_from NUMBER NOT NULL,
560 rd_namespace NUMBER DEFAULT 0 NOT NULL,
561 rd_title VARCHAR2(255) NOT NULL,
562 rd_interwiki VARCHAR2(32),
563 rd_fragment VARCHAR2(255)
564 );
565 ALTER TABLE &mw_prefix.redirect ADD CONSTRAINT &mw_prefix.redirect_fk1 FOREIGN KEY (rd_from) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
566 CREATE INDEX &mw_prefix.redirect_i01 ON &mw_prefix.redirect (rd_namespace,rd_title,rd_from);
567
568 CREATE TABLE &mw_prefix.querycachetwo (
569 qcc_type VARCHAR2(32) NOT NULL,
570 qcc_value NUMBER DEFAULT 0 NOT NULL,
571 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
572 qcc_title VARCHAR2(255),
573 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
574 qcc_titletwo VARCHAR2(255)
575 );
576 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
577 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
578 CREATE INDEX &mw_prefix.querycachetwo_i03 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
579
580 CREATE SEQUENCE page_restrictions_pr_id_seq;
581 CREATE TABLE &mw_prefix.page_restrictions (
582 pr_id NUMBER NOT NULL,
583 pr_page NUMBER NOT NULL,
584 pr_type VARCHAR2(255) NOT NULL,
585 pr_level VARCHAR2(255) NOT NULL,
586 pr_cascade NUMBER NOT NULL,
587 pr_user NUMBER NULL,
588 pr_expiry TIMESTAMP(6) WITH TIME ZONE NULL
589 );
590 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_pk PRIMARY KEY (pr_id);
591 ALTER TABLE &mw_prefix.page_restrictions ADD CONSTRAINT &mw_prefix.page_restrictions_fk1 FOREIGN KEY (pr_page) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
592 CREATE UNIQUE INDEX &mw_prefix.page_restrictions_u01 ON &mw_prefix.page_restrictions (pr_page,pr_type);
593 CREATE INDEX &mw_prefix.page_restrictions_i01 ON &mw_prefix.page_restrictions (pr_type,pr_level);
594 CREATE INDEX &mw_prefix.page_restrictions_i02 ON &mw_prefix.page_restrictions (pr_level);
595 CREATE INDEX &mw_prefix.page_restrictions_i03 ON &mw_prefix.page_restrictions (pr_cascade);
596
597 CREATE TABLE &mw_prefix.protected_titles (
598 pt_namespace NUMBER DEFAULT 0 NOT NULL,
599 pt_title VARCHAR2(255) NOT NULL,
600 pt_user NUMBER NOT NULL,
601 pt_reason VARCHAR2(255),
602 pt_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
603 pt_expiry VARCHAR2(14) NOT NULL,
604 pt_create_perm VARCHAR2(60) NOT NULL
605 );
606 CREATE UNIQUE INDEX &mw_prefix.protected_titles_u01 ON &mw_prefix.protected_titles (pt_namespace,pt_title);
607 CREATE INDEX &mw_prefix.protected_titles_i01 ON &mw_prefix.protected_titles (pt_timestamp);
608
609 CREATE TABLE &mw_prefix.page_props (
610 pp_page NUMBER NOT NULL,
611 pp_propname VARCHAR2(60) NOT NULL,
612 pp_value BLOB NOT NULL
613 );
614 CREATE UNIQUE INDEX &mw_prefix.page_props_u01 ON &mw_prefix.page_props (pp_page,pp_propname);
615
616
617 CREATE TABLE &mw_prefix.updatelog (
618 ul_key VARCHAR2(255) NOT NULL,
619 ul_value BLOB
620 );
621 ALTER TABLE &mw_prefix.updatelog ADD CONSTRAINT &mw_prefix.updatelog_pk PRIMARY KEY (ul_key);
622
623 CREATE TABLE &mw_prefix.change_tag (
624 ct_id NUMBER NOT NULL,
625 ct_rc_id NUMBER NULL,
626 ct_log_id NUMBER NULL,
627 ct_rev_id NUMBER NULL,
628 ct_tag VARCHAR2(255) NOT NULL,
629 ct_params BLOB NULL
630 );
631 ALTER TABLE &mw_prefix.change_tag ADD CONSTRAINT &mw_prefix.change_tag_pk PRIMARY KEY (ct_id);
632 CREATE UNIQUE INDEX &mw_prefix.change_tag_u01 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
633 CREATE UNIQUE INDEX &mw_prefix.change_tag_u02 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
634 CREATE UNIQUE INDEX &mw_prefix.change_tag_u03 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
635 CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
636
637 CREATE TABLE &mw_prefix.tag_summary (
638 ts_id NUMBER NOT NULL,
639 ts_rc_id NUMBER NULL,
640 ts_log_id NUMBER NULL,
641 ts_rev_id NUMBER NULL,
642 ts_tags BLOB NOT NULL
643 );
644 ALTER TABLE &mw_prefix.tag_summary ADD CONSTRAINT &mw_prefix.tag_summary_pk PRIMARY KEY (ts_id);
645 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u01 ON &mw_prefix.tag_summary (ts_rc_id);
646 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u02 ON &mw_prefix.tag_summary (ts_log_id);
647 CREATE UNIQUE INDEX &mw_prefix.tag_summary_u03 ON &mw_prefix.tag_summary (ts_rev_id);
648
649 CREATE TABLE &mw_prefix.valid_tag (
650 vt_tag VARCHAR2(255) NOT NULL
651 );
652 ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY KEY (vt_tag);
653
654 -- This table is not used unless profiling is turned on
655 --CREATE TABLE &mw_prefix.profiling (
656 -- pf_count NUMBER DEFAULT 0 NOT NULL,
657 -- pf_time NUMBER(18,10) DEFAULT 0 NOT NULL,
658 -- pf_memory NUMBER(18,10) DEFAULT 0 NOT NULL,
659 -- pf_name VARCHAR2(255),
660 -- pf_server VARCHAR2(30)
661 --);
662 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
663
664 CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
665 CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
666
667 CREATE TABLE &mw_prefix.l10n_cache (
668 lc_lang varchar2(32) NOT NULL,
669 lc_key varchar2(255) NOT NULL,
670 lc_value clob NOT NULL
671 );
672 CREATE INDEX &mw_prefix.l10n_cache_u01 ON &mw_prefix.l10n_cache (lc_lang, lc_key);
673
674 CREATE TABLE &mw_prefix.module_deps (
675 md_module VARCHAR2(255) NOT NULL,
676 md_skin VARCHAR2(32) NOT NULL,
677 md_deps BLOB NOT NULL
678 );
679 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
680
681 CREATE SEQUENCE sites_site_id_seq MINVALUE 0 START WITH 0;
682 CREATE TABLE &mw_prefix.sites (
683 site_id NUMBER NOT NULL,
684 site_global_key VARCHAR2(32) NOT NULL,
685 site_type VARCHAR2(32) NOT NULL,
686 site_group VARCHAR2(32) NOT NULL,
687 site_source VARCHAR2(32) NOT NULL,
688 site_language VARCHAR2(32) NOT NULL,
689 site_protocol VARCHAR2(32) NOT NULL,
690 site_domain VARCHAR2(255) NOT NULL,
691 site_data BLOB NOT NULL,
692 site_forward NUMBER(1) NOT NULL,
693 site_config BLOB NOT NULL
694 );
695 ALTER TABLE &mw_prefix.sites ADD CONSTRAINT &mw_prefix.sites_pk PRIMARY KEY (site_id);
696 CREATE UNIQUE INDEX &mw_prefix.sites_u01 ON &mw_prefix.sites (site_global_key);
697 CREATE INDEX &mw_prefix.sites_i01 ON &mw_prefix.sites (site_type);
698 CREATE INDEX &mw_prefix.sites_i02 ON &mw_prefix.sites (site_group);
699 CREATE INDEX &mw_prefix.sites_i03 ON &mw_prefix.sites (site_source);
700 CREATE INDEX &mw_prefix.sites_i04 ON &mw_prefix.sites (site_language);
701 CREATE INDEX &mw_prefix.sites_i05 ON &mw_prefix.sites (site_protocol);
702 CREATE INDEX &mw_prefix.sites_i06 ON &mw_prefix.sites (site_domain);
703 CREATE INDEX &mw_prefix.sites_i07 ON &mw_prefix.sites (site_forward);
704
705 CREATE TABLE &mw_prefix.site_identifiers (
706 si_site NUMBER NOT NULL,
707 si_type VARCHAR2(32) NOT NULL,
708 si_key VARCHAR2(32) NOT NULL
709 );
710 CREATE UNIQUE INDEX &mw_prefix.site_identifiers_u01 ON &mw_prefix.site_identifiers (si_type, si_key);
711 CREATE INDEX &mw_prefix.site_identifiers_i01 ON &mw_prefix.site_identifiers (si_site);
712 CREATE INDEX &mw_prefix.site_identifiers_i02 ON &mw_prefix.site_identifiers (si_key);
713
714 -- do not prefix this table as it breaks parserTests
715 CREATE TABLE wiki_field_info_full (
716 table_name VARCHAR2(35) NOT NULL,
717 column_name VARCHAR2(35) NOT NULL,
718 data_default VARCHAR2(4000),
719 data_length NUMBER NOT NULL,
720 data_type VARCHAR2(106),
721 not_null CHAR(1) NOT NULL,
722 prim NUMBER(1),
723 uniq NUMBER(1),
724 nonuniq NUMBER(1)
725 );
726 ALTER TABLE wiki_field_info_full ADD CONSTRAINT wiki_field_info_full_pk PRIMARY KEY (table_name, column_name);
727
728 /*$mw$*/
729 CREATE PROCEDURE fill_wiki_info IS
730 BEGIN
731 DELETE wiki_field_info_full;
732
733 FOR x_rec IN (SELECT t.table_name table_name, t.column_name,
734 t.data_default, t.data_length, t.data_type,
735 DECODE (t.nullable, 'Y', '1', 'N', '0') not_null,
736 (SELECT 1
737 FROM user_cons_columns ucc,
738 user_constraints uc
739 WHERE ucc.table_name = t.table_name
740 AND ucc.column_name = t.column_name
741 AND uc.constraint_name = ucc.constraint_name
742 AND uc.constraint_type = 'P'
743 AND ROWNUM < 2) prim,
744 (SELECT 1
745 FROM user_ind_columns uic,
746 user_indexes ui
747 WHERE uic.table_name = t.table_name
748 AND uic.column_name = t.column_name
749 AND ui.index_name = uic.index_name
750 AND ui.uniqueness = 'UNIQUE'
751 AND ROWNUM < 2) uniq,
752 (SELECT 1
753 FROM user_ind_columns uic,
754 user_indexes ui
755 WHERE uic.table_name = t.table_name
756 AND uic.column_name = t.column_name
757 AND ui.index_name = uic.index_name
758 AND ui.uniqueness = 'NONUNIQUE'
759 AND ROWNUM < 2) nonuniq
760 FROM user_tab_columns t, user_tables ut
761 WHERE ut.table_name = t.table_name)
762 LOOP
763 INSERT INTO wiki_field_info_full
764 (table_name, column_name,
765 data_default, data_length,
766 data_type, not_null, prim,
767 uniq, nonuniq
768 )
769 VALUES (x_rec.table_name, x_rec.column_name,
770 x_rec.data_default, x_rec.data_length,
771 x_rec.data_type, x_rec.not_null, x_rec.prim,
772 x_rec.uniq, x_rec.nonuniq
773 );
774 END LOOP;
775 COMMIT;
776 END;
777 /*$mw$*/
778
779 /*$mw$*/
780 CREATE OR REPLACE PROCEDURE duplicate_table(p_tabname IN VARCHAR2,
781 p_oldprefix IN VARCHAR2,
782 p_newprefix IN VARCHAR2,
783 p_temporary IN BOOLEAN) IS
784 e_table_not_exist EXCEPTION;
785 PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
786 l_temp_ei_sql VARCHAR2(2000);
787 l_temporary BOOLEAN := p_temporary;
788 BEGIN
789 BEGIN
790 EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
791 ' CASCADE CONSTRAINTS PURGE';
792 EXCEPTION
793 WHEN e_table_not_exist THEN
794 NULL;
795 END;
796 IF (p_tabname = 'SEARCHINDEX') THEN
797 l_temporary := FALSE;
798 END IF;
799 IF (l_temporary) THEN
800 EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
801 p_tabname ||
802 ' ON COMMIT PRESERVE ROWS AS SELECT * FROM ' ||
803 p_oldprefix || p_tabname || ' WHERE ROWNUM = 0';
804 ELSE
805 EXECUTE IMMEDIATE 'CREATE TABLE ' || p_newprefix || p_tabname ||
806 ' AS SELECT * FROM ' || p_oldprefix || p_tabname ||
807 ' WHERE ROWNUM = 0';
808 END IF;
809 FOR rc IN (SELECT column_name, data_default
810 FROM user_tab_columns
811 WHERE table_name = p_oldprefix || p_tabname
812 AND data_default IS NOT NULL) LOOP
813 EXECUTE IMMEDIATE 'ALTER TABLE ' || p_newprefix || p_tabname ||
814 ' MODIFY ' || rc.column_name || ' DEFAULT ' ||
815 SUBSTR(rc.data_default, 1, 2000);
816 END LOOP;
817 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('CONSTRAINT',
818 constraint_name),
819 32767,
820 1),
821 USER || '"."' || p_oldprefix,
822 USER || '"."' || p_newprefix),
823 '"' || constraint_name || '"',
824 '"' || p_newprefix || constraint_name || '"') DDLVC2,
825 constraint_name
826 FROM user_constraints uc
827 WHERE table_name = p_oldprefix || p_tabname
828 AND constraint_type = 'P') LOOP
829 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
830 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
831 1,
832 INSTR(l_temp_ei_sql,
833 ')',
834 INSTR(l_temp_ei_sql, 'PRIMARY KEY') + 1) + 1);
835 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
836 EXECUTE IMMEDIATE l_temp_ei_sql;
837 END IF;
838 END LOOP;
839 IF (NOT l_temporary) THEN
840 FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
841 constraint_name),
842 32767,
843 1),
844 USER || '"."' || p_oldprefix,
845 USER || '"."' || p_newprefix) DDLVC2,
846 constraint_name
847 FROM user_constraints uc
848 WHERE table_name = p_oldprefix || p_tabname
849 AND constraint_type = 'R') LOOP
850 IF nvl(length(l_temp_ei_sql), 0) > 0 AND
851 INSTR(l_temp_ei_sql, 'PRIMARY KEY') = 0 THEN
852 EXECUTE IMMEDIATE l_temp_ei_sql;
853 END IF;
854 END LOOP;
855 END IF;
856 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
857 index_name),
858 32767,
859 1),
860 USER || '"."' || p_oldprefix,
861 USER || '"."' || p_newprefix),
862 '"' || index_name || '"',
863 '"' || p_newprefix || index_name || '"') DDLVC2,
864 index_name,
865 index_type
866 FROM user_indexes ui
867 WHERE table_name = p_oldprefix || p_tabname
868 AND index_type NOT IN ('LOB', 'DOMAIN')
869 AND NOT EXISTS
870 (SELECT NULL
871 FROM user_constraints
872 WHERE table_name = ui.table_name
873 AND constraint_name = ui.index_name)) LOOP
874 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'PCTFREE') - 1);
875 l_temp_ei_sql := SUBSTR(l_temp_ei_sql,
876 1,
877 INSTR(l_temp_ei_sql,
878 ')',
879 INSTR(l_temp_ei_sql,
880 '"' || USER || '"."' || p_newprefix || '"') + 1) + 1);
881 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
882 EXECUTE IMMEDIATE l_temp_ei_sql;
883 END IF;
884 END LOOP;
885 FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
886 index_name),
887 32767,
888 1),
889 USER || '"."' || p_oldprefix,
890 USER || '"."' || p_newprefix),
891 '"' || index_name || '"',
892 '"' || p_newprefix || index_name || '"') DDLVC2,
893 index_name,
894 index_type
895 FROM user_indexes ui
896 WHERE table_name = p_oldprefix || p_tabname
897 AND index_type = 'DOMAIN'
898 AND NOT EXISTS
899 (SELECT NULL
900 FROM user_constraints
901 WHERE table_name = ui.table_name
902 AND constraint_name = ui.index_name)) LOOP
903 l_temp_ei_sql := rc.ddlvc2;
904 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
905 EXECUTE IMMEDIATE l_temp_ei_sql;
906 END IF;
907 END LOOP;
908 FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
909 trigger_name),
910 32767,
911 1)),
912 USER || '"."' || p_oldprefix,
913 USER || '"."' || p_newprefix),
914 ' ON ' || p_oldprefix || p_tabname,
915 ' ON ' || p_newprefix || p_tabname) DDLVC2,
916 trigger_name
917 FROM user_triggers
918 WHERE table_name = p_oldprefix || p_tabname) LOOP
919 l_temp_ei_sql := SUBSTR(rc.ddlvc2, 1, INSTR(rc.ddlvc2, 'ALTER ') - 1);
920 IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
921 EXECUTE IMMEDIATE l_temp_ei_sql;
922 END IF;
923 END LOOP;
924 END;
925
926 /*$mw$*/
927
928 /*$mw$*/
929 CREATE OR REPLACE FUNCTION BITOR (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
930 BEGIN
931 RETURN (x + y - BITAND(x, y));
932 END;
933 /*$mw$*/
934
935 /*$mw$*/
936 CREATE OR REPLACE FUNCTION BITNOT (x IN NUMBER) RETURN NUMBER AS
937 BEGIN
938 RETURN (4294967295 - x);
939 END;
940 /*$mw$*/
941
942 CREATE OR REPLACE TYPE GET_OUTPUT_TYPE IS TABLE OF VARCHAR2(255);
943
944 /*$mw$*/
945 CREATE OR REPLACE FUNCTION GET_OUTPUT_LINES RETURN GET_OUTPUT_TYPE PIPELINED AS
946 v_line VARCHAR2(255);
947 v_status INTEGER := 0;
948 BEGIN
949
950 LOOP
951 DBMS_OUTPUT.GET_LINE(v_line, v_status);
952 IF (v_status = 0) THEN RETURN; END IF;
953 PIPE ROW (v_line);
954 END LOOP;
955 RETURN;
956 EXCEPTION
957 WHEN OTHERS THEN
958 RETURN;
959 END;
960 /*$mw$*/
961
962 /*$mw$*/
963 CREATE OR REPLACE FUNCTION GET_SEQUENCE_VALUE(seq IN VARCHAR2) RETURN NUMBER AS
964 v_value NUMBER;
965 BEGIN
966 EXECUTE IMMEDIATE 'SELECT '||seq||'.NEXTVAL INTO :outVar FROM DUAL' INTO v_value;
967 RETURN v_value;
968 END;
969 /*$mw$*/