Bug 10636: DBrev 3.13.00.030
[koha.git] / installer / data / mysql / updatedatabase.pl
index d88b258..5c020cb 100755 (executable)
@@ -7162,6 +7162,107 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.13.00.024";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;});
+    print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.13.00.025";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+   $dbh->do("ALTER TABLE oai_sets_mappings ADD COLUMN operator varchar(8) NOT NULL default 'equal' AFTER marcsubfield;");
+   print "Upgrade to $DBversion done (Bug 9295: OAI notequal: add operator column to OAI mappings table)\n";
+   SetVersion ($DBversion);
+}
+
+$DBversion = "3.13.00.026";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE auth_subfield_structure ADD COLUMN defaultvalue TEXT DEFAULT NULL AFTER frameworkcode
+    |);
+    print "Upgrade to $DBversion done (Bug 10602: Add the column auth_subfield_structure.defaultvalue)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.027";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo')");
+    print "Upgrade to $DBversion done (Bug 10240: Add syspref AllowOfflineCirculation)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.13.00.028";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        ALTER TABLE export_format ADD type VARCHAR(255) DEFAULT 'marc' AFTER encoding
+    });
+    $dbh->do(q{
+        ALTER TABLE export_format CHANGE marcfields content mediumtext NOT NULL
+    });
+    print "Upgrade to $DBversion done (Bug 10853: Add new field export_format.type and rename export_format.marcfields with export_format.content)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.029";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type ) 
+        VALUES ( "issues to claim", "efault CSV export for serial issue claims",
+                "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate", 
+                ",", "sql" )
+    });
+    print "Upgrade to $DBversion done (Bug 10854: Add the default CSV profile for claiming issues)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.030";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(qq{
+        DELETE FROM patronimage WHERE NOT EXISTS (SELECT * FROM borrowers WHERE borrowers.cardnumber = patronimage.cardnumber)
+    });
+
+    $dbh->do(qq{
+        ALTER TABLE patronimage ADD borrowernumber INT( 11 ) NULL FIRST
+    });
+
+    $dbh->{AutoCommit} = 0;
+    $dbh->{RaiseError} = 1;
+
+    eval {
+        $dbh->do(qq{
+            UPDATE patronimage LEFT JOIN borrowers USING ( cardnumber ) SET patronimage.borrowernumber = borrowers.borrowernumber
+        });
+        $dbh->commit();
+    };
+
+    if ($@) {
+        print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber) failed! Transaction aborted because $@\n";
+        eval { $dbh->rollback };
+    }
+    else {
+        $dbh->do(qq{
+            ALTER TABLE patronimage DROP FOREIGN KEY patronimage_fk1
+        });
+        $dbh->do(qq{
+            ALTER TABLE patronimage DROP PRIMARY KEY, ADD PRIMARY KEY( borrowernumber )
+        });
+        $dbh->do(qq{
+            ALTER TABLE patronimage DROP cardnumber
+        });
+        $dbh->do(qq{
+            ALTER TABLE patronimage ADD FOREIGN KEY ( borrowernumber ) REFERENCES borrowers ( borrowernumber ) ON DELETE CASCADE ON UPDATE CASCADE
+        });
+
+        print "Upgrade to $DBversion done (Bug 10636 - patronimage should have borrowernumber as PK, not cardnumber)\n";
+        SetVersion($DBversion);
+    }
+
+    $dbh->{AutoCommit} = 1;
+    $dbh->{RaiseError} = 0;
+}
+
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)