Skip to content

PostgreSQL schema verification crashes on now() timestamp defaults #5733

Closed

Description

@abdallahshaban557

Serverpod version

4.0.0

Description

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

  1. Create a model with a timestamp default, for example:

    createdAt: DateTime, default=now
  2. Apply the generated migration to PostgreSQL.

  3. Run Serverpod 4.0.0 with migration application enabled.

  4. During schema verification, PostgreSQL returns now() for the timestamp default.

  5. 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.

Activity

  1. abdallahshaban557 commented on Sep 19, 2026

    @abdallahshaban557
    Author

    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!

  2. marcelomendoncasoares commented on Sep 23, 2026

    @marcelomendoncasoares
    Collaborator

    Thanks for reporting, @abdallahshaban557! We're fixing the support for tables with managedMigration: false and we'll fix this one together.

  3. added
    bug
    area: migrations
    on Sep 23, 2026
  4. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Sep 23, 2026
  5. abdallahshaban557 commented on Sep 24, 2026

    @abdallahshaban557
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: migrationsbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions