From bd40bee1aaf6ebc3bdc7eb93d6366c677a6b7c9e Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 30 Oct 2007 19:16:47 -0500 Subject: [PATCH] added auto_number column as PK for action_logs * prevents PK warnings when logging actions that occur faster than once a second (e.g., batch MARC loads) -- the original PK of timestamp + user not granular enough * timestamp + user still indexed for log viewing Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- installer/kohastructure.sql | 4 +++- kohaversion.pl | 2 +- updater/updatedatabase | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index 5bbf29a33f..61bb52b152 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -59,13 +59,15 @@ CREATE TABLE `accountoffsets` ( DROP TABLE IF EXISTS `action_logs`; CREATE TABLE `action_logs` ( + `action_id` int(11) NOT NULL auto_increment, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `user` int(11) NOT NULL default 0, `module` text, `action` text, `object` int(11) default NULL, `info` text, - PRIMARY KEY (`timestamp`,`user`) + PRIMARY KEY (`action_id`), + KEY (`timestamp`,`user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/kohaversion.pl b/kohaversion.pl index b4abdda92d..737f24d7c7 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -8,7 +8,7 @@ # and is automatically called by Auth.pm when needed. sub kohaversion { - return "3.00.00.016"; + return "3.00.00.017"; } 1; diff --git a/updater/updatedatabase b/updater/updatedatabase index 7f031151db..599e0c6874 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -504,6 +504,16 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.017"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY"); + $dbh->do("ALTER TABLE action_logs ADD KEY timestamp (timestamp,user)"); + $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST"); + $dbh->do("UPDATE action_logs SET action_id = if (@a, @a:=@a+1, @a:=1)"); + $dbh->do("ALTER TABLE action_logs MODIFY action_id AUTO_INCREMENT PRIMARY KEY"); + print "Upgrade to $DBversion done (added column to action_logs)\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) -- 2.39.2