Bug 21250: DBRev 19.12.00.010
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 15 Jan 2020 16:17:41 +0000 (16:17 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 15 Jan 2020 16:27:53 +0000 (16:27 +0000)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha.pm
Koha/Schema/Result/OaiSetsMapping.pm
installer/data/mysql/atomicupdate/bug_21520.perl [deleted file]
installer/data/mysql/kohastructure.sql
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index 989ad48..23cb34a 100644 (file)
--- a/Koha.pm
+++ b/Koha.pm
@@ -29,7 +29,7 @@ use vars qw{ $VERSION };
 # - #4 : the developer version. The 4th number is the database subversion.
 #        used by developers when the database changes. updatedatabase take care of the changes itself
 #        and is automatically called by Auth.pm when needed.
-$VERSION = "19.12.00.009";
+$VERSION = "19.12.00.010";
 
 sub version {
     return $VERSION;
index e4dd532..2ba58ed 100644 (file)
@@ -29,6 +29,18 @@ __PACKAGE__->table("oai_sets_mappings");
   is_foreign_key: 1
   is_nullable: 0
 
+=head2 rule_order
+
+  data_type: 'integer'
+  is_nullable: 0
+
+=head2 rule_operator
+
+  data_type: 'varchar'
+  default_value: 'or'
+  is_nullable: 0
+  size: 3
+
 =head2 marcfield
 
   data_type: 'char'
@@ -59,6 +71,10 @@ __PACKAGE__->table("oai_sets_mappings");
 __PACKAGE__->add_columns(
   "set_id",
   { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+  "rule_order",
+  { data_type => "integer", is_nullable => 0 },
+  "rule_operator",
+  { data_type => "varchar", default_value => "or", is_nullable => 0, size => 3 },
   "marcfield",
   { data_type => "char", is_nullable => 0, size => 3 },
   "marcsubfield",
@@ -92,8 +108,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:A2fchnI85JftSuruZ1CykQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-01-15 16:27:11
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:70uqCB/wqEodblvsbKKVvA
 
 
 # You can replace this text with custom content, and it will be preserved on regeneration
diff --git a/installer/data/mysql/atomicupdate/bug_21520.perl b/installer/data/mysql/atomicupdate/bug_21520.perl
deleted file mode 100644 (file)
index ccf3178..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-    $dbh->do( "ALTER TABLE oai_sets_mappings ADD COLUMN rule_order INT AFTER set_id, ADD COLUMN rule_operator VARCHAR(3) AFTER rule_order" );
-    $dbh->do( "UPDATE oai_sets_mappings SET rule_operator='or'" );
-    my $sets = $dbh->selectall_arrayref("SELECT * from oai_sets_mappings ORDER BY set_id", { Slice => {} });
-    my $i = 0;
-    my $previous_set_id;
-    for my $set ( @{$sets}) {
-        my $set_id = $set->{set_id};
-
-        if ($previous_set_id && $previous_set_id != $set_id) {
-            $i = 0;
-        }
-
-        if ($i == 0) {
-            $dbh->do("UPDATE oai_sets_mappings SET rule_operator=NULL WHERE set_id=? LIMIT 1", {}, $set_id);
-        }
-
-        $dbh->do("UPDATE oai_sets_mappings SET rule_order=? WHERE set_id=? AND rule_order IS NULL LIMIT 1", {}, $i, $set_id);
-
-        $i++;
-        $previous_set_id = $set_id;
-    }
-
-    # Always end with this (adjust the bug info)
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 21520 - Add rule_order and rule_operator fields to oai_sets_mappings table)\n";
-}
index 56d5d27..da0d740 100644 (file)
@@ -1219,6 +1219,8 @@ CREATE TABLE `oai_sets_descriptions` (
 DROP TABLE IF EXISTS `oai_sets_mappings`;
 CREATE TABLE `oai_sets_mappings` (
   `set_id` int(11) NOT NULL,
+  `rule_order` int NOT NULL,
+  `rule_operator` varchar(3) NOT NULL default 'or',
   `marcfield` char(3) NOT NULL,
   `marcsubfield` char(1) NOT NULL,
   `operator` varchar(8) NOT NULL default 'equal',
index e45c398..61eb449 100755 (executable)
@@ -20485,6 +20485,36 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`,
     print "Upgrade to $DBversion done (Bug 23354 - Add point of sale permissions)\n";
 }
 
+$DBversion = '19.12.00.010';
+if( CheckVersion( $DBversion ) ) {
+    if( !column_exists( 'oai_sets_mappings', 'rule_order' ) ) {
+        $dbh->do( "ALTER TABLE oai_sets_mappings ADD COLUMN rule_order INT AFTER set_id, ADD COLUMN rule_operator VARCHAR(3) AFTER rule_order" );
+        $dbh->do( "UPDATE oai_sets_mappings SET rule_operator='or'" );
+        my $sets = $dbh->selectall_arrayref("SELECT * from oai_sets_mappings ORDER BY set_id", { Slice => {} });
+        my $i = 0;
+        my $previous_set_id;
+        for my $set ( @{$sets}) {
+            my $set_id = $set->{set_id};
+    
+            if ($previous_set_id && $previous_set_id != $set_id) {
+                $i = 0;
+            }
+    
+            if ($i == 0) {
+                $dbh->do("UPDATE oai_sets_mappings SET rule_operator=NULL WHERE set_id=? LIMIT 1", {}, $set_id);
+            }
+    
+            $dbh->do("UPDATE oai_sets_mappings SET rule_order=? WHERE set_id=? AND rule_order IS NULL LIMIT 1", {}, $i, $set_id);
+    
+            $i++;
+            $previous_set_id = $set_id;
+        }
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 21520 - Add rule_order and rule_operator fields to oai_sets_mappings table)\n";
+}
+
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';