From 973f9013a4f21c02426cd76b2a69ebac598b064a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Mar 2020 10:45:47 +0100 Subject: [PATCH] Bug 15272: DB changes Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_15272.perl | 37 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 5 +-- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15272.perl diff --git a/installer/data/mysql/atomicupdate/bug_15272.perl b/installer/data/mysql/atomicupdate/bug_15272.perl new file mode 100644 index 0000000000..c10f595792 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15272.perl @@ -0,0 +1,37 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + unless ( column_exists('aqbooksellers', 'address') ) { + $dbh->do(q| + ALTER TABLE aqbooksellers + ADD COLUMN address LONGTEXT + AFTER name + |); + $dbh->do(q| + UPDATE aqbooksellers + SET address = CONCAT(address1, "\r\n", address2, "\r\n", address3, "\r\n", address4) + |); + $dbh->do(q| + ALTER TABLE aqbooksellers + DROP COLUMN address1, + DROP COLUMN address2, + DROP COLUMN address3, + DROP COLUMN address4 + |); + $dbh->do(q| + UPDATE letter SET content=REPLACE(content, "<>\n<>\n<>\n<>\n", "<>\n"); + |); + + my $occurrences_left = $dbh->selectall_arrayref(q| + SELECT code, name + FROM letter + WHERE content LIKE "%address4%" + |); + for my $o ( @$occurrences_left ) { + warn sprintf "Letter '%s' (%s) still use 'address4' from aqbooksellers, but the column has been removed (same for address1, address2 and address3)" + } + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 15272 - Merge columns aqbooksellers.addressX into address)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4308bcdc21..2e873dec1e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2778,10 +2778,7 @@ DROP TABLE IF EXISTS `aqbooksellers`; CREATE TABLE `aqbooksellers` ( -- information about the vendors listed in acquisitions `id` int(11) NOT NULL auto_increment, -- primary key and unique identifier assigned by Koha `name` LONGTEXT NOT NULL, -- vendor name - `address1` LONGTEXT, -- first line of vendor physical address - `address2` LONGTEXT, -- second line of vendor physical address - `address3` LONGTEXT, -- third line of vendor physical address - `address4` LONGTEXT, -- fourth line of vendor physical address + `address` LONGTEXT, -- vendor physical address `phone` varchar(30) default NULL, -- vendor phone number `accountnumber` LONGTEXT, -- vendor account number `notes` LONGTEXT, -- order notes -- 2.20.1