From 0dccd472762a258224a8e7ab14bae07c4296a2ef Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Mon, 25 Nov 2024 11:30:29 +0000 Subject: [PATCH] Bug 37592: (QA follow-up) Update db_rev to align DBIx::Class with database schema for creation_date, modification_date - DBIx::Class appears to determine column nullability based on database metadata. When columns are added via `ALTER TABLE` without explicitly specifying `NOT NULL`, the metadata may indicate `IS_NULLABLE = "YES"`, causing DBIx::Class to generate `is_nullable => 1` in the schema files. This behavior might not account for the implicit `NOT NULL` enforcement of `DEFAULT CURRENT_TIMESTAMP`. - Adding `NOT NULL` explicitly in the `ALTER TABLE` statements ensures the database metadata reflects the intended constraints, potentially resolving this issue. - Additionally, comments in the atomic update and `kohastructure.sql` are aligned for consistency and clarity. --- installer/data/mysql/db_revs/240600029.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 installer/data/mysql/db_revs/240600029.pl diff --git a/installer/data/mysql/db_revs/240600029.pl b/installer/data/mysql/db_revs/240600029.pl old mode 100755 new mode 100644 index 34130aa521..760561001f --- a/installer/data/mysql/db_revs/240600029.pl +++ b/installer/data/mysql/db_revs/240600029.pl @@ -25,10 +25,10 @@ return { } 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' + ALTER TABLE bookings ADD COLUMN creation_date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT 'the datetime for when a bookings was created' SQL 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' + ALTER TABLE bookings ADD COLUMN modification_date DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL COMMENT 'the datetime for when a booking has been updated' SQL if ( @{$existing_columns} == 0 ) { $dbh->do("$creation_date_statement AFTER `end_date`"); -- 2.39.5