Bugzilla – Attachment 184396 Details for
Bug 40337
checkprevcheckout must be defined as ENUM at DB level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40337: (QA follow-up) Make database update idempotent
Bug-40337-QA-follow-up-Make-database-update-idempo.patch (text/plain), 4.38 KB, created by
Martin Renvoize (ashimema)
on 2025-07-18 15:02:58 UTC
(
hide
)
Description:
Bug 40337: (QA follow-up) Make database update idempotent
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-18 15:02:58 UTC
Size:
4.38 KB
patch
obsolete
>From 45f857ce0d4f28c049834f56c93d3f33838d59bd Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 18 Jul 2025 16:01:31 +0100 >Subject: [PATCH] Bug 40337: (QA follow-up) Make database update idempotent > >Running this update twice fails before this patch with: > >ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Data truncated for column 'checkprevcheckout' at row 3 at /kohadevbox/koha/C4/Installer.pm line 825 >--- > installer/data/mysql/db_revs/250600003.pl | 61 ++++++++++++++++++----- > 1 file changed, 49 insertions(+), 12 deletions(-) > >diff --git a/installer/data/mysql/db_revs/250600003.pl b/installer/data/mysql/db_revs/250600003.pl >index 951097d56dd..db13e2bfa76 100755 >--- a/installer/data/mysql/db_revs/250600003.pl >+++ b/installer/data/mysql/db_revs/250600003.pl >@@ -8,25 +8,62 @@ return { > my ($args) = @_; > my ( $dbh, $out ) = @$args{qw(dbh out)}; > >- $dbh->do( >+ my $col_type_borrowers = $dbh->selectrow_array( > q{ >- ALTER TABLE borrowers >- MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.' >- } >+ SELECT COLUMN_TYPE >+ FROM INFORMATION_SCHEMA.COLUMNS >+ WHERE TABLE_SCHEMA = DATABASE() >+ AND TABLE_NAME = 'borrowers' >+ AND COLUMN_NAME = 'checkprevcheckout' >+ } > ); > >- $dbh->do( >- q{ >- ALTER TABLE categories >- MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.' >+ if ( $col_type_borrowers ne "enum('yes','no','inherit')" ) { >+ $dbh->do( >+ q{ >+ ALTER TABLE borrowers >+ MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.' >+ } >+ ); > } >- ); > >- $dbh->do( >+ my $col_type_categories = $dbh->selectrow_array( > q{ >- ALTER TABLE deletedborrowers >- MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.' >+ SELECT COLUMN_TYPE >+ FROM INFORMATION_SCHEMA.COLUMNS >+ WHERE TABLE_SCHEMA = DATABASE() >+ AND TABLE_NAME = 'categories' >+ AND COLUMN_NAME = 'checkprevcheckout' >+ } >+ ); >+ >+ if ( $col_type_categories ne "enum('yes','no','inherit')" ) { >+ >+ $dbh->do( >+ q{ >+ ALTER TABLE categories >+ MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.' >+ } >+ ); > } >+ >+ my $col_type_deletedborrowers = $dbh->selectrow_array( >+ q{ >+ SELECT COLUMN_TYPE >+ FROM INFORMATION_SCHEMA.COLUMNS >+ WHERE TABLE_SCHEMA = DATABASE() >+ AND TABLE_NAME = 'deletedborrowers' >+ AND COLUMN_NAME = 'checkprevcheckout' >+ } > ); >+ >+ if ( $col_type_deletedborrowers ne "enum('yes','no','inherit')" ) { >+ $dbh->do( >+ q{ >+ ALTER TABLE deletedborrowers >+ MODIFY COLUMN `checkprevcheckout` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.' >+ } >+ ); >+ } > }, > }; >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40337
:
183918
|
183919
|
183946
|
183947
|
183948
|
183969
|
183970
|
184396
|
184397
|
184425
|
184856