Bug 14826: DBRev 17.06.00.017
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 20:06:49 +0000 (17:06 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 20:14:33 +0000 (17:14 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha.pm
installer/data/mysql/atomicupdate/bug_14826.sql [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index b776d19..fc07db9 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 = "17.06.00.016";
+$VERSION = "17.06.00.017";
 
 sub version {
     return $VERSION;
diff --git a/installer/data/mysql/atomicupdate/bug_14826.sql b/installer/data/mysql/atomicupdate/bug_14826.sql
deleted file mode 100644 (file)
index 6ef3eba..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-DROP TABLE IF EXISTS `accountoffsets`;
-
-CREATE TABLE IF NOT EXISTS `account_offset_types` (
-  `type` varchar(16) NOT NULL, -- The type of offset this is
-  PRIMARY KEY (`type`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-CREATE TABLE IF NOT EXISTS `account_offsets` (
-  `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
-  `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
-  `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
-  `type` varchar(16) NOT NULL, -- The type of offset this is
-  `amount` decimal(26,6) NOT NULL, -- The amount of the change
-  `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
-  PRIMARY KEY (`id`),
-  CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
-  CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
-INSERT IGNORE INTO account_offset_types ( type ) VALUES
-('Writeoff'),
-('Payment'),
-('Lost Item'),
-('Manual Debit'),
-('Reverse Payment'),
-('Forgiven'),
-('Dropbox'),
-('Rental Fee'),
-('Fine Update'),
-('Fine');
index ef00974..f559378 100755 (executable)
@@ -14772,6 +14772,54 @@ if( CheckVersion( $DBversion ) ) {
     print "Upgrade to $DBversion done (Bug 18298 - Allow enforcing password complexity (system preference RequireStrongPassword))\n";
 }
 
+$DBversion = '17.06.00.017';
+if( CheckVersion( $DBversion ) ) {
+    unless (TableExists('account_offsets')) {
+        $dbh->do(q{
+            DROP TABLE IF EXISTS `accountoffsets`;
+        });
+
+        $dbh->do(q{
+            CREATE TABLE IF NOT EXISTS `account_offset_types` (
+              `type` varchar(16) NOT NULL, -- The type of offset this is
+              PRIMARY KEY (`type`)
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+        });
+
+        $dbh->do(q{
+            CREATE TABLE IF NOT EXISTS `account_offsets` (
+              `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
+              `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
+              `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
+              `type` varchar(16) NOT NULL, -- The type of offset this is
+              `amount` decimal(26,6) NOT NULL, -- The amount of the change
+              `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
+              PRIMARY KEY (`id`),
+              CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+              CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+              CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+        });
+
+        $dbh->do(q{
+            INSERT IGNORE INTO account_offset_types ( type ) VALUES
+            ('Writeoff'),
+            ('Payment'),
+            ('Lost Item'),
+            ('Manual Debit'),
+            ('Reverse Payment'),
+            ('Forgiven'),
+            ('Dropbox'),
+            ('Rental Fee'),
+            ('Fine Update'),
+            ('Fine');
+        });
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 14826 - Resurrect account offsets table (Add new tables account_offsets and account_offset_types))\n";
+}
+
 # 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.