From 57f911c45c2d1a434243633b4b178a8775597593 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 24 Aug 2015 16:18:37 +0800 Subject: Bug 1196092 - Switch logincookies primary key to auto_incremented id, make cookie a secondary UNIQUE key --- Bugzilla/DB/Schema.pm | 5 +++-- Bugzilla/Install/DB.pm | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 975fa7067..dbcffac7c 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -1138,17 +1138,18 @@ use constant ABSTRACT_SCHEMA => { logincookies => { FIELDS => [ - cookie => {TYPE => 'varchar(22)', NOTNULL => 1, - PRIMARYKEY => 1}, + cookie => {TYPE => 'varchar(22)', NOTNULL => 1}, userid => {TYPE => 'INT3', NOTNULL => 1, REFERENCES => {TABLE => 'profiles', COLUMN => 'userid', DELETE => 'CASCADE'}}, ipaddr => {TYPE => 'varchar(40)'}, lastused => {TYPE => 'DATETIME', NOTNULL => 1}, + id => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1}, ], INDEXES => [ logincookies_lastused_idx => ['lastused'], + logincookies_cookie_idx => {FIELDS => ['cookie'], TYPE => 'UNIQUE'}, ], }, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 02777d7f1..ce148d62d 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -733,8 +733,14 @@ sub update_table_definitions { # 2015-07-25 dylan@mozilla.com - Bug 1179856 $dbh->bz_alter_column('tokens', 'token', {TYPE => 'varchar(22)', NOTNULL => 1, PRIMARYKEY => 1}); + + # 2015-08-20 dylan@mozilla.com - Bug 1196092 $dbh->bz_alter_column('logincookies', 'cookie', - {TYPE => 'varchar(22)', NOTNULL => 1, PRIMARYKEY => 1}); + {TYPE => 'varchar(22)', NOTNULL => 1}); + $dbh->bz_add_index('logincookies', 'logincookies_cookie_idx', + {TYPE => 'UNIQUE', FIELDS => ['cookie']}); + $dbh->bz_add_column('logincookies', 'id', + {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); $dbh->bz_add_column('user_api_keys', 'last_used_ip', {TYPE => 'varchar(40)'}); -- cgit v1.2.3-24-g4f1b