1 -- Add extra option fields to the ipblocks table, add some extra indexes,
2 -- convert infinity values in ipb_expiry to something that sorts better,
3 -- extend ipb_address and range fields, add a unique index for block conflict
6 -- Conflicts in the new unique index can be handled by creating a new
7 -- table and inserting into it instead of doing an ALTER TABLE.
10 DROP TABLE IF EXISTS /*$wgDBprefix*/ipblocks_newunique;
12 CREATE TABLE /*$wgDBprefix*/ipblocks_newunique (
13 ipb_id int NOT NULL auto_increment,
14 ipb_address tinyblob NOT NULL,
15 ipb_user int unsigned NOT NULL default '0',
16 ipb_by int unsigned NOT NULL default '0',
17 ipb_reason tinyblob NOT NULL,
18 ipb_timestamp binary(14) NOT NULL default '',
19 ipb_auto bool NOT NULL default 0,
20 ipb_anon_only bool NOT NULL default 0,
21 ipb_create_account bool NOT NULL default 1,
22 ipb_expiry varbinary(14) NOT NULL default '',
23 ipb_range_start tinyblob NOT NULL,
24 ipb_range_end tinyblob NOT NULL,
26 PRIMARY KEY ipb_id (ipb_id),
27 UNIQUE INDEX ipb_address_unique (ipb_address(255), ipb_user, ipb_auto),
28 INDEX ipb_user (ipb_user),
29 INDEX ipb_range (ipb_range_start(8), ipb_range_end(8)),
30 INDEX ipb_timestamp (ipb_timestamp),
31 INDEX ipb_expiry (ipb_expiry)
33 ) /*$wgDBTableOptions*/;
35 INSERT IGNORE INTO /*$wgDBprefix*/ipblocks_newunique
36 (ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, ipb_anon_only, ipb_create_account)
37 SELECT ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, 0 , ipb_user=0
38 FROM /*$wgDBprefix*/ipblocks;
40 DROP TABLE IF EXISTS /*$wgDBprefix*/ipblocks_old;
41 RENAME TABLE /*$wgDBprefix*/ipblocks TO /*$wgDBprefix*/ipblocks_old;
42 RENAME TABLE /*$wgDBprefix*/ipblocks_newunique TO /*$wgDBprefix*/ipblocks;
44 UPDATE /*$wgDBprefix*/ipblocks SET ipb_expiry='infinity' WHERE ipb_expiry='';