From 326b4c046e361c79bc40ad29a3f8d0859e161001 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Sun, 14 Feb 2016 12:50:00 +0000 Subject: [PATCH] Bug 9021: DBrev 3.23.000.020 Signed-off-by: Kyle M Hall --- Koha/Schema/Result/Borrower.pm | 8 ++--- Koha/Schema/Result/Deletedborrower.pm | 11 +++++-- .../data/mysql/atomicupdate/bug_9021.sql | 14 --------- installer/data/mysql/updatedatabase.pl | 30 +++++++++++++++++++ 4 files changed, 43 insertions(+), 20 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_9021.sql diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index 4094b44e66..39880aa918 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1053,8 +1053,8 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, join_type => "LEFT", - on_delete => "RESTRICT", - on_update => "RESTRICT", + on_delete => "SET NULL", + on_update => "CASCADE", }, ); @@ -1204,8 +1204,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-12-31 16:48:38 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dd1tdtsFTruFwsmCZU6ogQ +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-02-14 12:46:14 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bI6qJYw+ulTUwA7XMCkkRw __PACKAGE__->belongs_to( "guarantor", diff --git a/Koha/Schema/Result/Deletedborrower.pm b/Koha/Schema/Result/Deletedborrower.pm index 315903500e..57cea85d13 100644 --- a/Koha/Schema/Result/Deletedborrower.pm +++ b/Koha/Schema/Result/Deletedborrower.pm @@ -387,6 +387,11 @@ __PACKAGE__->table("deletedborrowers"); is_nullable: 1 size: 50 +=head2 sms_provider_id + + data_type: 'integer' + is_nullable: 1 + =head2 privacy data_type: 'integer' @@ -550,6 +555,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 50 }, "smsalertnumber", { data_type => "varchar", is_nullable => 1, size => 50 }, + "sms_provider_id", + { data_type => "integer", is_nullable => 1 }, "privacy", { data_type => "integer", default_value => 1, is_nullable => 0 }, "privacy_guarantor_checkouts", @@ -557,8 +564,8 @@ __PACKAGE__->add_columns( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-06 12:00:28 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aNmdXpOz+XN5abM67sl8uA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-02-14 12:46:14 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UvGAnZ1qOwgtmLpbG8ukow # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_9021.sql b/installer/data/mysql/atomicupdate/bug_9021.sql deleted file mode 100644 index c1c4660230..0000000000 --- a/installer/data/mysql/atomicupdate/bug_9021.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE sms_providers ( - id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , - name VARCHAR( 255 ) NOT NULL , - domain VARCHAR( 255 ) NOT NULL , - UNIQUE ( - name - ) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -ALTER TABLE borrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber; -ALTER TABLE borrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL; - -ALTER TABLE deletedborrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber; -ALTER TABLE deletedborrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8ee4088e8a..ba4fee9e6d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -11733,6 +11733,36 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.23.00.020"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + CREATE TABLE sms_providers ( + id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , + name VARCHAR( 255 ) NOT NULL , + domain VARCHAR( 255 ) NOT NULL , + UNIQUE ( + name + ) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + }); + + $dbh->do(q{ + ALTER TABLE borrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber; + }); + $dbh->do(q{ + ALTER TABLE borrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL; + }); + $dbh->do(q{ + ALTER TABLE deletedborrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber; + }); + $dbh->do(q{ + ALTER TABLE deletedborrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL; + }); + + print "Upgrade to $DBversion done (Bug 9021 - Add SMS via email as an alternative to SMS services via SMS::Send drivers)\n"; + SetVersion($DBversion); +} + # 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.39.5