From e75c1ac012b8f12322e713f45f94e0054a84f58d Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Mon, 16 Sep 2024 10:06:38 +0000 Subject: [PATCH] Bug 37592: (QA follow-up) Change created_on, updated_on to creation_date, modification_date It makes sense not to introduce mapping code if there's no reason for it. Accordingly the the columns are now of type DATETIME instead. Signed-off-by: Katrin Fischer --- Koha/Booking.pm | 5 +-- ...2-add_created_at_updated_at_to_bookings.pl | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Koha/Booking.pm b/Koha/Booking.pm index 403ca3bf4e..e5297d8d17 100644 --- a/Koha/Booking.pm +++ b/Koha/Booking.pm @@ -241,10 +241,7 @@ on the API. =cut sub to_api_mapping { - return { - created_on => "creation_date", - updated_on => "modification_date" - }; + return {}; } =head3 delete diff --git a/installer/data/mysql/atomicupdate/bug_37592-add_created_at_updated_at_to_bookings.pl b/installer/data/mysql/atomicupdate/bug_37592-add_created_at_updated_at_to_bookings.pl index 2177a85ee8..0c95f4f425 100755 --- a/installer/data/mysql/atomicupdate/bug_37592-add_created_at_updated_at_to_bookings.pl +++ b/installer/data/mysql/atomicupdate/bug_37592-add_created_at_updated_at_to_bookings.pl @@ -3,7 +3,7 @@ use Koha::Installer::Output qw(say_warning say_failure say_success say_info); return { bug_number => '37592', - description => 'Add created_on, updated_on fields to bookings table', + description => 'Add creation_date, modification_date fields to bookings table', up => sub { my ($args) = @_; my ( $dbh, $out ) = @{$args}{qw(dbh out)}; @@ -12,50 +12,53 @@ return { SELECT column_name FROM information_schema.COLUMNS WHERE table_name = 'bookings' - AND column_name IN ('created_on', 'updated_on') + AND column_name IN ('creation_date', 'modification_date') SQL my $existing_columns = $dbh->selectcol_arrayref($columns_exist_query); if ( @{$existing_columns} == 2 ) { - say_info( $out, q{Columns 'created_on' and 'updated_on' already exist in 'bookings' table. Skipping...} ); + say_info( + $out, + q{Columns 'creation_date' and 'modification_date' already exist in 'bookings' table. Skipping...} + ); return; } - my $created_on_statement = <<~'SQL'; - ALTER TABLE bookings ADD COLUMN created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'The timestamp for when a bookings was created' + my $creation_date_statement = <<~'SQL'; + ALTER TABLE bookings ADD COLUMN creation_date DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT 'The datetime for when a bookings was created' SQL - my $updated_on_statement = <<~'SQL'; - ALTER TABLE bookings ADD COLUMN updated_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'The timestamp for when a booking has been updated' + my $modification_date_statement = <<~'SQL'; + ALTER TABLE bookings ADD COLUMN modification_date DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'The datetime for when a booking has been updated' SQL if ( @{$existing_columns} == 0 ) { - if ( $dbh->do("$created_on_statement AFTER `end_date`") ) { - say_success( $out, q{Added column 'bookings.created_on'} ); + if ( $dbh->do("$creation_date_statement AFTER `end_date`") ) { + say_success( $out, q{Added column 'bookings.creation_date'} ); } else { - say_failure( $out, q{Failed to add column 'bookings.created_on': } . $dbh->errstr ); + say_failure( $out, q{Failed to add column 'bookings.creation_date': } . $dbh->errstr ); } - if ( $dbh->do("$updated_on_statement AFTER `created_on`") ) { - say_success( $out, q{Added column 'bookings.updated_on'} ); + if ( $dbh->do("$modification_date_statement AFTER `creation_date`") ) { + say_success( $out, q{Added column 'bookings.modification_date'} ); } else { - say_failure( $out, q{Failed to add column 'bookings.updated_on': } . $dbh->errstr ); + say_failure( $out, q{Failed to add column 'bookings.modification_date': } . $dbh->errstr ); } return; } if ( @{$existing_columns} == 1 ) { - foreach my $column ( 'created_on', 'updated_on' ) { + foreach my $column ( 'creation_date', 'modification_date' ) { if ( column_exists( 'bookings', $column ) ) { next; } my $statement; - if ( $column eq 'created_on' ) { - $statement = "$created_on_statement AFTER `end_date`"; + if ( $column eq 'creation_date' ) { + $statement = "$creation_date_statement AFTER `end_date`"; } - if ( $column eq 'updated_on' ) { - $statement = "$updated_on_statement AFTER `created_on`"; + if ( $column eq 'modification_date' ) { + $statement = "$modification_date_statement AFTER `creation_date`"; } if ( $dbh->do($statement) ) { -- 2.39.5