From 34a1433bbe1c5d649665da299f936beff896171f Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 24 Sep 2018 08:28:16 +0200 Subject: [PATCH] Bug 21401: Add column transaction_library to table account_offsets --- .../bug_21401_account_offsets_transaction_library.perl | 10 ++++++++++ installer/data/mysql/kohastructure.sql | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_21401_account_offsets_transaction_library.perl diff --git a/installer/data/mysql/atomicupdate/bug_21401_account_offsets_transaction_library.perl b/installer/data/mysql/atomicupdate/bug_21401_account_offsets_transaction_library.perl new file mode 100644 index 0000000..f65ffce --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_21401_account_offsets_transaction_library.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'account_offsets', 'transaction_library' ) ) { + $dbh->do( "ALTER TABLE account_offsets ADD COLUMN transaction_library varchar(10) default NULL AFTER created_on" ); + $dbh->do( "ALTER TABLE account_offsets ADD CONSTRAINT `account_offsets_ibfk_l` FOREIGN KEY (`transaction_library`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE" ); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 21401 - Add transacting library to account_offsets)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 49a0f18..96c623d 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2717,10 +2717,12 @@ CREATE TABLE `account_offsets` ( `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, + `transaction_library` varchar(10) default NULL, -- library where the offset was made 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 + CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `account_offsets_ibfk_l` FOREIGN KEY (`transaction_library`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.1.4