Schema proposal based on T194697#4490343
CREATE TABLE block_target ( bt_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, bt_address tinyblob NOT NULL, bt_user int unsigned NOT NULL default 0, bt_auto bool NOT NULL default 0, bt_range_start tinyblob NOT NULL, bt_range_end tinyblob NOT NULL, bt_count int NOT NULL default 0 ); CREATE UNIQUE INDEX bt_address ON block_target (bt_address(255), bt_user, bt_auto); CREATE INDEX bt_user ON block_target (bt_user); CREATE INDEX bt_range ON block_target (bt_range_start(8), bt_range_end(8)); CREATE TABLE block_entry ( be_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, be_target int NOT NULL, be_by_actor bigint unsigned NOT NULL DEFAULT 0, be_reason_id bigint unsigned NOT NULL DEFAULT 0, be_timestamp binary(14) NOT NULL default '', be_anon_only bool NOT NULL default 0, be_create_account bool NOT NULL default 1, be_enable_autoblock bool NOT NULL default '1', be_expiry varbinary(14) NOT NULL default '', be_deleted bool NOT NULL default 0, be_block_email bool NOT NULL default 0, be_allow_usertalk bool NOT NULL default 0, be_parent_id int default NULL, be_sitewide bool NOT NULL default 1 ); CREATE INDEX be_timestamp ON block_entry (be_timestamp); CREATE INDEX be_expiry ON block_entry (be_expiry); CREATE INDEX be_parent_id ON block_entry (be_parent_id); CREATE TABLE block_entry_restrictions ( ber_be_id int NOT NULL, ber_type tinyint(1) NOT NULL, ber_value int NOT NULL, PRIMARY KEY (ber_be_id, ber_type, ber_value) ); CREATE INDEX ber_type_value ON block_entry_restrictions (ber_type, ber_value);
This schema is effectively splitting the existing ipblocks into two tables block_target and block_entry and renaming ipblocks_restrictions to block_entry_restrictions. This will allow multiple block entries for the same target to coexist.