Bug 11430: DB changes: Add the primary key for search_history
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 20 Dec 2013 14:03:16 +0000 (15:03 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 11 Mar 2015 18:02:47 +0000 (15:02 -0300)
Adds a primary key search_history.id.

Signed-off-by: sonia BOUIS <sonia.bouis@univ-lyon3.fr>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl

index 1408216..5738dae 100644 (file)
@@ -1939,6 +1939,7 @@ CREATE TABLE saved_reports (
 
 DROP TABLE IF EXISTS `search_history`;
 CREATE TABLE IF NOT EXISTS `search_history` ( -- patron's opac search history
+  `ìd` int(11) NOT NULL auto_increment, -- search history id
   `userid` int(11) NOT NULL, -- the patron who performed the search (borrowers.borrowernumber)
   `sessionid` varchar(32) NOT NULL, -- a system generated session id
   `query_desc` varchar(255) NOT NULL, -- the search that was performed
@@ -1948,6 +1949,7 @@ CREATE TABLE IF NOT EXISTS `search_history` ( -- patron's opac search history
   `time` timestamp NOT NULL default CURRENT_TIMESTAMP, -- the date and time the search was run
   KEY `userid` (`userid`),
   KEY `sessionid` (`sessionid`)
+  PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Opac search history results';
 
 
index dbcd9b2..d81ffa4 100755 (executable)
@@ -9793,7 +9793,6 @@ if(CheckVersion($DBversion)) {
     SetVersion($DBversion);
 }
 
-
 $DBversion = "3.19.00.013";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q|
@@ -9824,6 +9823,15 @@ if ( CheckVersion($DBversion) ) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.19.00.XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id);
+    |);
+    print "Upgrade to $DBversion done (Bug 11430 - Add primary key for search_history)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)