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 <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Galen Charlton 2007-10-30 19:16:47 -05:00 committed by Joshua Ferraro
parent b5e18fe431
commit bd40bee1aa
3 changed files with 14 additions and 2 deletions

View File

@ -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;
--

View File

@ -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;

View File

@ -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)