Bug 37711: DB update

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2024-08-22 15:13:01 -03:00 committed by Laura Escamilla
parent ea9fba54d3
commit 6ad376dfb8
No known key found for this signature in database
GPG Key ID: B5DEB5FD2FCDA5D8
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,52 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
return {
bug_number => "37711",
description => "Allow setting auto-register per interface (identity providers)",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
if ( !column_exists( 'identity_provider_domains', 'auto_register_opac' ) ) {
$dbh->do(
q{
ALTER TABLE identity_provider_domains
ADD COLUMN `auto_register_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)'
AFTER `allow_staff`;
}
);
say_success( $out, "Added column 'identity_provider_domains.auto_register_opac'" );
}
if ( !column_exists( 'identity_provider_domains', 'auto_register_staff' ) ) {
$dbh->do(
q{
ALTER TABLE identity_provider_domains
ADD COLUMN `auto_register_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (Staff interface)'
AFTER `auto_register_opac`;
}
);
say_success( $out, "Added column 'identity_provider_domains.auto_register_staff'" );
}
# if this is a sane upgrade, then the column exists and to keep the current
# behavior we only enable OPAC auto-register, if enabled previously
if ( column_exists( 'identity_provider_domains', 'auto_register' ) ) {
$dbh->do(
q{
UPDATE identity_provider_domains
SET auto_register_opac=auto_register;
}
);
$dbh->do(
q{
ALTER TABLE identity_provider_domains
DROP COLUMN `auto_register`;
}
);
say_success( $out, "Removed column 'identity_provider_domains.auto_register'" );
}
},
};

View File

@ -3585,12 +3585,13 @@ CREATE TABLE `identity_provider_domains` (
`identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
`identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
`domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
`auto_register` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register',
`update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
`default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
`default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
`allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
`allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
`auto_register_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)',
`auto_register_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (Staff interface)',
PRIMARY KEY (`identity_provider_domain_id`),
UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
KEY `domain` (`domain`),