Bug 33671: Fix for 30472 - Remove null-guarantors

These guarantors cannot be added. They are of no use.

NOTE FOR QA/RM: I do not think that it is needed to add a new
db rev for this change since it happens seldom. But if you think
that it is, just copy it to atomicupdate/change bugno.

Test plan:
[1] Check your table definition and modify it:
    alter table borrower_relationships modify column `guarantor_id` int(11) NULL;
[2] Add an empty guarantor:
    insert into borrower_relationships (guarantee_id,relationship) values (SOME_PATRON_ID,'father');
[3] Run the dbrev and verify that the inserted record has been removed.
[4] Check table definition with 'show create table borrower_relationships'.
    You should see NOT NULL with guarantor_id.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-05-04 06:41:19 +00:00 committed by Tomas Cohen Arazi
parent 6fafe5e05b
commit 1dee35d412
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -6,6 +6,11 @@ return {
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
# Delete 'empty' guarantors. No longer possible to add them via interface. Have no use.
$dbh->do(q{
DELETE FROM borrower_relationships WHERE guarantor_id IS NULL
});
$dbh->do(q{
ALTER TABLE borrower_relationships CHANGE COLUMN guarantor_id guarantor_id int(11) NOT NULL
});