Bug 9580: DBRev 3.19.00.019
[koha_ffzg] / installer / data / mysql / updatedatabase.pl
index 01c5544..0592a94 100755 (executable)
@@ -38,7 +38,6 @@ use C4::Context;
 use C4::Installer;
 use C4::Dates;
 
-use File::Slurp;
 use MARC::Record;
 use MARC::File::XML ( BinaryEncoding => 'utf8' );
 
@@ -4942,44 +4941,52 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
 
 $DBversion = "3.07.00.029";
 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
-    $dbh->do(qq{
-DROP TABLE IF EXISTS `oai_sets_descriptions`;
-DROP TABLE IF EXISTS `oai_sets_mappings`;
-DROP TABLE IF EXISTS `oai_sets_biblios`;
-DROP TABLE IF EXISTS `oai_sets`;
-
-CREATE TABLE `oai_sets` (
-  `id` int(11) NOT NULL auto_increment,
-  `spec` varchar(80) NOT NULL UNIQUE,
-  `name` varchar(80) NOT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;});
+    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;});
+    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;});
+    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;});
 
-CREATE TABLE `oai_sets_descriptions` (
-  `set_id` int(11) NOT NULL,
-  `description` varchar(255) NOT NULL,
-  CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    $dbh->do(q{
+        CREATE TABLE `oai_sets` (
+          `id` int(11) NOT NULL auto_increment,
+          `spec` varchar(80) NOT NULL UNIQUE,
+          `name` varchar(80) NOT NULL,
+          PRIMARY KEY (`id`)
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    });
 
-CREATE TABLE `oai_sets_mappings` (
-  `set_id` int(11) NOT NULL,
-  `marcfield` char(3) NOT NULL,
-  `marcsubfield` char(1) NOT NULL,
-  `marcvalue` varchar(80) NOT NULL,
-  CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    $dbh->do(q{
+        CREATE TABLE `oai_sets_descriptions` (
+          `set_id` int(11) NOT NULL,
+          `description` varchar(255) NOT NULL,
+          CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    });
 
-CREATE TABLE `oai_sets_biblios` (
-  `biblionumber` int(11) NOT NULL,
-  `set_id` int(11) NOT NULL,
-  PRIMARY KEY (`biblionumber`, `set_id`),
-  CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    $dbh->do(q{
+        CREATE TABLE `oai_sets_mappings` (
+          `set_id` int(11) NOT NULL,
+          `marcfield` char(3) NOT NULL,
+          `marcsubfield` char(1) NOT NULL,
+          `marcvalue` varchar(80) NOT NULL,
+          CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    });
 
-INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo');
+    $dbh->do(q{
+        CREATE TABLE `oai_sets_biblios` (
+          `biblionumber` int(11) NOT NULL,
+          `set_id` int(11) NOT NULL,
+          PRIMARY KEY (`biblionumber`, `set_id`),
+          CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
+          CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+    });
+
+    $dbh->do(q{
+        INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo');
+    });
 
-});
     print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
     SetVersion($DBversion);
 }
@@ -9937,21 +9944,47 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.19.00.018";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        UPDATE systempreferences set variable="OpacAdditionalStylesheet" WHERE variable="opaccolorstylesheet"
+    |);
+    print "Upgrade to $DBversion done (Bug 10328: Rename opaccolorstylesheet to OpacAdditionalStylesheet\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.019";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
+        VALUES('Coce','0', 'If on, enables cover retrieval from the configured Coce server', NULL, 'YesNo')
+    });
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
+        VALUES('CoceHost', NULL, 'Coce server URL', NULL,'Free')
+    });
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
+        VALUES('CoceProviders', NULL, 'Coce providers', 'aws,gb,ol', 'multiple')
+    });
+    print "Upgrade to $DBversion done (Bug 9580: Cover image from Coce, a remote image URL cache)\n";
+    SetVersion($DBversion);
+}
+
+
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
 
-opendir( my $dirh, C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate' );
-my $old_delimiter = $/;
-$/ = ';';
-while (readdir $dirh) {
-    next unless $_ =~ /\.sql$/; # skip non SQL files
-    print "DEV atomic update : $_ \n";
+my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
+opendir( my $dirh, $update_dir );
+while ( my $file = readdir $dirh ) {
+    next unless $file =~ /\.sql$/;    # skip non SQL files
+    print "DEV atomic update : $file \n";
     my $installer = C4::Installer->new();
-    my $rv = $installer->load_sql( C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/' . $_ )? 0: 1;
+    my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
 }
 
-
 =head1 FUNCTIONS
 
 =head2 TableExists($table)