From 3dda7d6c7fa683f910aeacdf89658af8ee9755cd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 20 Sep 2018 13:02:20 +0000 Subject: [PATCH] Bug 20819: DBRev 18.06.00.031 Signed-off-by: Nick Clemens --- Koha.pm | 2 +- Koha/Schema/Result/Borrower.pm | 19 ++- Koha/Schema/Result/BorrowerModification.pm | 16 ++- Koha/Schema/Result/PatronConsent.pm | 118 ++++++++++++++++++ .../data/mysql/atomicupdate/bug_20819.perl | 22 ---- installer/data/mysql/updatedatabase.pl | 24 ++++ 6 files changed, 174 insertions(+), 27 deletions(-) create mode 100644 Koha/Schema/Result/PatronConsent.pm delete mode 100644 installer/data/mysql/atomicupdate/bug_20819.perl diff --git a/Koha.pm b/Koha.pm index 4a2fd0c33d..ec09477a6b 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 = "18.06.00.030"; +$VERSION = "18.06.00.031"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index ab0fefc3bc..236c917912 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -1145,6 +1145,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 patron_consents + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "patron_consents", + "Koha::Schema::Result::PatronConsent", + { "foreign.borrowernumber" => "self.borrowernumber" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 patron_list_patrons Type: has_many @@ -1401,8 +1416,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-30 15:33:44 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4C4USKLUfuOaydGmIfeOnQ +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-20 13:00:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QT6EPIG26F/kNK6prauRgw __PACKAGE__->belongs_to( "guarantor", diff --git a/Koha/Schema/Result/BorrowerModification.pm b/Koha/Schema/Result/BorrowerModification.pm index 013da7753a..c91c58e712 100644 --- a/Koha/Schema/Result/BorrowerModification.pm +++ b/Koha/Schema/Result/BorrowerModification.pm @@ -415,6 +415,12 @@ __PACKAGE__->table("borrower_modifications"); data_type: 'mediumtext' is_nullable: 1 +=head2 gdpr_proc_consent + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + =cut __PACKAGE__->add_columns( @@ -581,6 +587,12 @@ __PACKAGE__->add_columns( { data_type => "integer", is_nullable => 1 }, "extended_attributes", { data_type => "mediumtext", is_nullable => 1 }, + "gdpr_proc_consent", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, ); =head1 PRIMARY KEY @@ -598,8 +610,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("verification_token", "borrowernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Vv0bJqR71Ust1MZAkYqTig +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-20 13:00:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qQ0BWngri+79YvK9S8zZPg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/PatronConsent.pm b/Koha/Schema/Result/PatronConsent.pm new file mode 100644 index 0000000000..3ba8b5d986 --- /dev/null +++ b/Koha/Schema/Result/PatronConsent.pm @@ -0,0 +1,118 @@ +use utf8; +package Koha::Schema::Result::PatronConsent; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::PatronConsent + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("patron_consent"); + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 borrowernumber + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 type + + data_type: 'enum' + extra: {list => ["GDPR_PROCESSING"]} + is_nullable: 1 + +=head2 given_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +=head2 refused_on + + data_type: 'datetime' + datetime_undef_if_invalid: 1 + is_nullable: 1 + +=cut + +__PACKAGE__->add_columns( + "id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "borrowernumber", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "type", + { + data_type => "enum", + extra => { list => ["GDPR_PROCESSING"] }, + is_nullable => 1, + }, + "given_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, + "refused_on", + { + data_type => "datetime", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 RELATIONS + +=head2 borrowernumber + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "borrowernumber", + "Koha::Schema::Result::Borrower", + { borrowernumber => "borrowernumber" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-20 13:00:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:as3b13eS31zkIPr9uxP7+A + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/installer/data/mysql/atomicupdate/bug_20819.perl b/installer/data/mysql/atomicupdate/bug_20819.perl deleted file mode 100644 index 99ffc08b78..0000000000 --- a/installer/data/mysql/atomicupdate/bug_20819.perl +++ /dev/null @@ -1,22 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - - # Add table and add column - $dbh->do(q| -CREATE TABLE patron_consent (id int AUTO_INCREMENT, borrowernumber int NOT NULL, type enum('GDPR_PROCESSING' ), given_on datetime, refused_on datetime, PRIMARY KEY (id), FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE ) - |); - $dbh->do(q| -ALTER TABLE borrower_modifications ADD COLUMN gdpr_proc_consent datetime - |); - - # Add two sysprefs too - $dbh->do(q| -INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('PrivacyPolicyURL','',NULL,'This URL is used in messages about GDPR consents.', 'Free') - |); - $dbh->do(q| -INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('GDPR_Policy','','Enforced\|Permissive\|Disabled','General Data Protection Regulation - policy', 'Choice') - |); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 20819: Add patron_consent)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a26dee6edd..85663fc688 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16419,6 +16419,30 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 20777 - Remove unused field accountlines.dispute)\n"; } +$DBversion = '18.06.00.031'; +if( CheckVersion( $DBversion ) ) { + # Add table and add column + unless (TableExists('patron_consent')) { + $dbh->do(q| + CREATE TABLE patron_consent (id int AUTO_INCREMENT, borrowernumber int NOT NULL, type enum('GDPR_PROCESSING' ), given_on datetime, refused_on datetime, PRIMARY KEY (id), FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE ) + |); + } + unless ( column_exists( 'borrower_modifications', 'gdpr_proc_consent' ) ) { + $dbh->do(q| + ALTER TABLE borrower_modifications ADD COLUMN gdpr_proc_consent datetime + |); + } + # Add two sysprefs too + $dbh->do(q| +INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('PrivacyPolicyURL','',NULL,'This URL is used in messages about GDPR consents.', 'Free') + |); + $dbh->do(q| +INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ('GDPR_Policy','','Enforced\|Permissive\|Disabled','General Data Protection Regulation - policy', 'Choice') + |); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 20819: Add patron_consent)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.2