[Koha-patches] [PATCH 4/5] Bug 2559 Added primary keys to tables per comments

Galen Charlton gmcharlt at gmail.com
Sun Sep 6 19:45:08 CEST 2009


From: Nicole Engard <nengard at gmail.com>

Signed-off-by: Galen Charlton <gmcharlt at gmail.com>
---
 installer/data/mysql/kohastructure.sql |    6 ++++++
 installer/data/mysql/updatedatabase.pl |    9 +++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 23e5b10..cdf7f42 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2138,6 +2138,8 @@ CREATE TABLE language_subtag_registry (
         type varchar(25), -- language-script-region-variant-extension-privateuse
         description varchar(25), -- only one of the possible descriptions for ease of reference, see language_descriptions for the complete list
         added date,
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
         KEY `subtag` (`subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -2148,6 +2150,8 @@ DROP TABLE IF EXISTS language_rfc4646_to_iso639;
 CREATE TABLE language_rfc4646_to_iso639 (
         rfc4646_subtag varchar(25),
         iso639_2_code varchar(25),
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
         KEY `rfc4646_subtag` (`rfc4646_subtag`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -2157,6 +2161,8 @@ CREATE TABLE language_descriptions (
         type varchar(25),
         lang varchar(25),
         description varchar(255),
+        id int(11) NOT NULL auto_increment,
+        PRIMARY KEY  (`id`),
         KEY `lang` (`lang`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 24154eb..fca65c4 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2634,6 +2634,15 @@ $DBversion = '3.01.00.XXX';
      SetVersion ($DBversion);
      print "Upgrade to $DBversion done (Bug 2576 : Add OPACFinesTab syspref)\n";
      }    
+     
+$DBversion = '3.01.00.XXX';
+     if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+     $dbh->do("ALTER TABLE `language_subtag_registry` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
+     $dbh->do("ALTER TABLE `language_rfc4646_to_iso639` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
+     $dbh->do("ALTER TABLE `language_descriptions` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY;");
+     SetVersion ($DBversion);
+     print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
+     }    
 
 =item DropAllForeignKeys($table)
 
-- 
1.6.3.3




More information about the Koha-patches mailing list