From 3b04f401b92ef96f0ca2dae05d8fec7dcce0ff7f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 20 Oct 2017 17:06:49 -0300 Subject: [PATCH] Bug 14826: DBRev 17.06.00.017 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_14826.sql | 31 ------------ installer/data/mysql/updatedatabase.pl | 48 +++++++++++++++++++ 3 files changed, 49 insertions(+), 32 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_14826.sql diff --git a/Koha.pm b/Koha.pm index b776d199ec..fc07db9c4e 100644 --- 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 index 6ef3eba13a..0000000000 --- a/installer/data/mysql/atomicupdate/bug_14826.sql +++ /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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index ef00974bbc..f559378b37 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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. -- 2.20.1