CREATE TABLE phpbb_sessions_keys (
	key_id varchar(32) DEFAULT '0' NOT NULL,
	user_id mediumint(8) DEFAULT '0' NOT NULL,
	last_ip varchar(8) DEFAULT '0' NOT NULL,
	last_login int(11) DEFAULT '0' NOT NULL,
	PRIMARY KEY (key_id, user_id),
	KEY last_login (last_login)
);

INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin','1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time','0');

UPDATE phpbb_users SET user_active = 0 WHERE user_id = -1;
INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('basic_data_updated', '0');
UPDATE phpbb_attachments_config SET config_value = '2.4.1' WHERE config_name='attach_version';

ALTER TABLE phpbb_users ADD COLUMN user_login_tries smallint(5) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD COLUMN user_last_login_try int(11) DEFAULT '0' NOT NULL;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_login_attempts', '5');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('login_reset_time', '30');

ALTER TABLE phpbb_search_results ADD COLUMN search_time int(11) DEFAULT '0' NOT NULL;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_flood_interval', '15');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('rand_seed', '0');
DELETE FROM phpbb_sessions;
DELETE FROM phpbb_sessions_keys;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_min_chars', '3');
ALTER TABLE phpbb_search_results MODIFY COLUMN search_array MEDIUMTEXT NOT NULL;
UPDATE phpbb_config SET config_value = '.0.22' WHERE config_name = 'version';