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.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Paul Derscheid 2024-11-25 11:30:29 +00:00 committed by Katrin Fischer
parent c0a8cf18f7
commit 4e5034eb08
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 2 additions and 2 deletions

4
installer/data/mysql/db_revs/240600029.pl Executable file → Normal file
View File

@ -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`");