From fac826c1942d6e39682d0c75a7497b07098f7930 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Sun, 21 Jul 2019 22:35:28 +0000 Subject: [PATCH] Bug 23352: Database and DBIx changes This patch contains the following changes: * Atomicupdate (this change is idempotent using the column_exists subroutine) * kohastructure.sql changes adding the new column 'ccode' to subscription table. * Change to Koha/Schema/Result/Subscription.pm to reflect the change to subscription table Test plan: 1. Enter mysql terminal: sudo koha-mysql 2. Run the query: describe subscription; 3. Notice there is no 'ccode' column after the 'mana_id' column 3. Exit mysql terminal and apply patch 4. Navigate to the installer/data/mysql directory 5. Enter koha-shell: sudo koha-shell 6. Run: ./updatedatabase.pl 7. Notice atomicupdate runs without errors 8. Exit koha-shell and re-enter mysql terminal and confirm the 'ccode' column is in the subscription table now after mana_id column 9. Exit mysql terminal and view the installer/data/mysql/kohastructure.sql file and notice 'ccode' is added to subscription table under mana_id column 10. Exit the file and view the Koha/Schema/Result/Subscription.pm file. Notice it has been updated on 22 July 2019 and it now contains 'ccode' Sponsored-By: Brimbank Library, Australia --- Koha/Schema/Result/Subscription.pm | 12 ++++++++++-- .../bug_23352-add_ccode_column_to_subscriptions_table.perl | 7 +++++++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23352-add_ccode_column_to_subscriptions_table.perl diff --git a/Koha/Schema/Result/Subscription.pm b/Koha/Schema/Result/Subscription.pm index 88b4325..0264eee 100644 --- a/Koha/Schema/Result/Subscription.pm +++ b/Koha/Schema/Result/Subscription.pm @@ -276,6 +276,12 @@ __PACKAGE__->table("subscription"); data_type: 'integer' is_nullable: 1 +=head2 ccode + + data_type: 'varchar' + is_nullable: 1 + size: 80 + =cut __PACKAGE__->add_columns( @@ -365,6 +371,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 10 }, "mana_id", { data_type => "integer", is_nullable => 1 }, + "ccode", + { data_type => "varchar", is_nullable => 1, size => 80 }, ); =head1 PRIMARY KEY @@ -452,8 +460,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-23 12:56:39 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dTb/JOO3KQ3NZGypFbRiEw +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2019-07-21 22:34:06 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TS3fIO7Y11bAkj73Ak8ouA __PACKAGE__->has_many( "additional_field_values", diff --git a/installer/data/mysql/atomicupdate/bug_23352-add_ccode_column_to_subscriptions_table.perl b/installer/data/mysql/atomicupdate/bug_23352-add_ccode_column_to_subscriptions_table.perl new file mode 100644 index 0000000..2420b47 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23352-add_ccode_column_to_subscriptions_table.perl @@ -0,0 +1,7 @@ + +unless ( column_exists('subscription', 'ccode')) { + $dbh->do(q{ + ALTER TABLE `subscription` + ADD `ccode` varchar (80) default NULL AFTER `mana_id` + }); +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 62effe9..f8d0a12 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2021,6 +2021,7 @@ CREATE TABLE `subscription` ( -- information related to the subscription `itemtype` VARCHAR( 10 ) NULL, `previousitemtype` VARCHAR( 10 ) NULL, `mana_id` int(11) NULL DEFAULT NULL, + `ccode` varchar(80) DEFAULT NULL, -- authorized value for the collection code associated with this item (MARC21 952$8) PRIMARY KEY (`subscriptionid`), KEY `by_biblionumber` (`biblionumber`), CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE, -- 2.1.4