Bug 20819: DBRev 18.06.00.031

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2018-09-20 13:02:20 +00:00
parent f6eb461516
commit 3dda7d6c7f
6 changed files with 174 additions and 27 deletions

View File

@ -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;

View File

@ -1145,6 +1145,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 patron_consents
Type: has_many
Related object: L<Koha::Schema::Result::PatronConsent>
=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</aqorder_users> -> 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",

View File

@ -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

View File

@ -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<patron_consent>
=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</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 borrowernumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=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;

View File

@ -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";
}

View File

@ -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.