Skip to content

fix(data): DEFAULT CURRENT_TIMESTAMP on CreatedAt/ModifiedAt#651

Merged
pitabwire merged 1 commit intomainfrom
fix/basemodel-created-at-default
Apr 20, 2026
Merged

fix(data): DEFAULT CURRENT_TIMESTAMP on CreatedAt/ModifiedAt#651
pitabwire merged 1 commit intomainfrom
fix/basemodel-created-at-default

Conversation

@pitabwire
Copy link
Copy Markdown
Owner

Follow-up to v1.94.5. Tagging NOT NULL alone broke raw SQL seed migrations that INSERT without specifying created_at/modified_at (tenant/partition/client seeds). Adding a column DEFAULT keeps those seeds working while preserving the NOT NULL invariant.

…iedAt

Follow-up to v1.94.5. Tagging the columns NOT NULL alone broke raw-SQL
seed migrations that INSERT without specifying created_at/modified_at
(hand-written tenant/partition/client seeds). Adding a column DEFAULT
keeps those seeds working while preserving the NOT NULL invariant
BeforeCreate already enforces for GORM-driven writes.

PostgreSQL uses CURRENT_TIMESTAMP; MySQL/SQLite accept the same literal
verbatim as a default expression.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the BaseModel struct in data/model.go by adding default:CURRENT_TIMESTAMP to the CreatedAt and ModifiedAt fields. This change ensures that these columns are correctly populated during raw SQL seed inserts and prevents GORM's AutoMigrate from relaxing column constraints. I have no feedback to provide as no review comments were submitted.

@pitabwire pitabwire merged commit c487e0b into main Apr 20, 2026
7 checks passed
@pitabwire pitabwire deleted the fix/basemodel-created-at-default branch April 20, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant