Bugzilla – Attachment 179455 Details for
Bug 38663
Add additional fields to libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38663: (follow-up) Make database update idempotent
Bug-38663-follow-up-Make-database-update-idempoten.patch (text/plain), 2.56 KB, created by
Martin Renvoize (ashimema)
on 2025-03-18 15:31:53 UTC
(
hide
)
Description:
Bug 38663: (follow-up) Make database update idempotent
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-03-18 15:31:53 UTC
Size:
2.56 KB
patch
obsolete
>From 9b406a12af1623cdf886f0e352e2edf2ed0d1f2e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 18 Mar 2025 15:31:15 +0000 >Subject: [PATCH] Bug 38663: (follow-up) Make database update idempotent > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > installer/data/mysql/db_revs/241200018.pl | 24 +++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > >diff --git a/installer/data/mysql/db_revs/241200018.pl b/installer/data/mysql/db_revs/241200018.pl >index 088f9349d1e..26e60713352 100755 >--- a/installer/data/mysql/db_revs/241200018.pl >+++ b/installer/data/mysql/db_revs/241200018.pl >@@ -1,5 +1,5 @@ > use Modern::Perl; >-use Koha::Installer::Output qw(say_warning say_success say_info); >+use Koha::Installer::Output qw(say_warning say_success( $out, say_info); > > return { > bug_number => "38663", >@@ -8,14 +8,26 @@ return { > my ($args) = @_; > my ( $dbh, $out ) = @$args{qw(dbh out)}; > >- $dbh->do(q{ ALTER TABLE additional_field_values ADD COLUMN new_record_id VARCHAR(11) NOT NULL DEFAULT ''; }); >+ my $sth = $dbh->prepare("SHOW COLUMNS FROM additional_field_values WHERE Field = 'record_id'"); >+ $sth->execute(); >+ my $column_info = $sth->fetchrow_hashref(); > >- $dbh->do(q{ UPDATE additional_field_values SET new_record_id = CAST(record_id AS CHAR(11)); }); >+ if ( $column_info && $column_info->{Type} eq 'int(11)' ) { > >- $dbh->do(q{ ALTER TABLE additional_field_values DROP COLUMN record_id; }); >+ # Only run the migration if record_id is still an integer type >+ say_info( $out, "Converting record_id from int(11) to VARCHAR(11)...\n"); > >- $dbh->do(q{ ALTER TABLE additional_field_values RENAME COLUMN new_record_id TO record_id; }); >+ $dbh->do( >+ q{ ALTER TABLE additional_field_values ADD COLUMN new_record_id VARCHAR(11) NOT NULL DEFAULT ''; }); >+ $dbh->do(q{ UPDATE additional_field_values SET new_record_id = CAST(record_id AS CHAR(11)); }); >+ $dbh->do(q{ ALTER TABLE additional_field_values DROP COLUMN record_id; }); >+ $dbh->do(q{ ALTER TABLE additional_field_values RENAME COLUMN new_record_id TO record_id; }); > >- say_success( $out, "Converted additional_field_values.record_id to VARCHAR" ); >+ say_success( $out, "Converted record_id to VARCHAR"); >+ } else { >+ >+ # Either the column doesn't exist or it's already been converted >+ say_info( $out, "No conversion needed for record_id column."); >+ } > }, > }; >-- >2.48.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 38663
:
175355
|
175356
|
175357
|
175358
|
175359
|
175370
|
175757
|
175758
|
175759
|
175760
|
175761
|
175762
|
176214
|
176215
|
176216
|
176217
|
176218
|
176219
|
176220
|
176221
|
176222
|
176223
|
176224
|
176225
|
176296
|
176781
|
176782
|
176783
|
176784
|
176785
|
176786
|
176787
|
176788
|
176797
|
176799
|
176800
|
176801
|
176802
|
176803
|
176804
|
176805
|
178843
|
178844
|
178845
|
178846
|
178847
|
178848
|
178849
|
178850
|
178914
| 179455 |
181910