You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PostgreSQL schema verification crashes on now() timestamp defaults #5733
When Serverpod verifies an existing PostgreSQL schema, PostgreSQL reports a CURRENT_TIMESTAMP column default as now(). Serverpod accepts CURRENT_TIMESTAMP, but does not recognize the equivalent now() form.
It then tries to parse now() as a date and fails:
FormatException: Invalid date format
now()Z
This prevents a migration job from completing, even when Serverpod has already confirmed that the latest migration is applied.
Reproduction
Create a model with a timestamp default, for example:
createdAt: DateTime, default=now
Apply the generated migration to PostgreSQL.
Run Serverpod 4.0.0 with migration application enabled.
During schema verification, PostgreSQL returns now() for the timestamp default.
Serverpod fails with FormatException: Invalid date format now()Z.
Expected behavior
Serverpod should treat PostgreSQL's now() and CURRENT_TIMESTAMP expressions as equivalent timestamp defaults and complete schema verification.
Likely cause
pgSqlToAbstractDefault recognizes only CURRENT_TIMESTAMP, then the timestamp parser appends Z to unrecognized values and attempts to parse now()Z as a date.
Suggested fix
Recognize now() alongside CURRENT_TIMESTAMP when parsing PostgreSQL timestamp defaults. A regression test covering a database-introspected now() default would prevent this from returning.
I can submit a PR to fix this if you prefer to just fix the now() handling - I can also submit a broader PR that can handle all different variations such as CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(), now(), transaction_timestamp(), and localtimestamp. I'd love to hear what the maintainers would prefer!
Activity
abdallahshaban557 commentedon Sep 19, 2026
I can submit a PR to fix this if you prefer to just fix the now() handling - I can also submit a broader PR that can handle all different variations such as CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(), now(), transaction_timestamp(), and localtimestamp. I'd love to hear what the maintainers would prefer!
marcelomendoncasoares commentedon Sep 23, 2026
Thanks for reporting, @abdallahshaban557! We're fixing the support for tables with
managedMigration: falseand we'll fix this one together.abdallahshaban557 commentedon Sep 24, 2026
Sounds good! @marcelomendoncasoares