Skip to content

Commit 4fef486

Browse files
committed
fix(db): correct migration history and fix timestamp nullability
1 parent 7a9670d commit 4fef486

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

backend/src/main/resources/db/migration/V12__Create_Homepage_Blocks.sql renamed to backend/src/main/resources/db/migration/common/V12__Create_Homepage_Blocks.sql

File renamed without changes.
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
-- V12: Make Timestamps Not Nullable
2-
-- This script updates the content table to ensure created_at and updated_at are not nullable,
3-
-- aligning the schema with the entity validation rules.
4-
5-
-- First, update existing null values to a sensible default (e.g., the publication_date)
6-
-- to avoid errors when applying the NOT NULL constraint.
7-
UPDATE content
8-
SET created_at = publication_date,
9-
updated_at = publication_date
10-
WHERE created_at IS NULL
11-
OR updated_at IS NULL;
12-
13-
-- Now, alter the table to enforce the NOT NULL constraint.
14-
-- The exact syntax can vary between database systems (e.g., MySQL vs. PostgreSQL).
15-
-- This syntax is generally compatible with MySQL.
16-
ALTER TABLE content
17-
MODIFY COLUMN created_at DATETIME NOT NULL,
18-
MODIFY COLUMN updated_at DATETIME NOT NULL;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- V13: Make Timestamps Not Nullable
2+
-- This script updates the content table to ensure created_at and updated_at are not nullable,
3+
-- aligning the schema with the entity validation rules.
4+
5+
-- First, update existing null values to a sensible default (e.g., the publication_date)
6+
-- to avoid errors when applying the NOT NULL constraint.
7+
UPDATE content
8+
SET created_at = publication_date,
9+
updated_at = publication_date
10+
WHERE created_at IS NULL
11+
OR updated_at IS NULL;
12+
13+
-- Now, alter the table to enforce the NOT NULL constraint.
14+
-- The exact syntax can vary between database systems (e.g., MySQL vs. PostgreSQL).
15+
-- This syntax is generally compatible with MySQL.
16+
ALTER TABLE content
17+
MODIFY COLUMN created_at DATETIME NOT NULL,
18+
MODIFY COLUMN updated_at DATETIME NOT NULL;

0 commit comments

Comments
 (0)