vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
146 stars 53 forks source link

Set a default timestamp #103

Closed grosch closed 4 years ago

grosch commented 5 years ago

Doesn't seem to be a way to set a default timestamp. I've tried all of these:

builder.field(for: \.date, type: .timestamptz, .default("timezone('UTC', now())"))
builder.field(for: \.date, type: .timestamptz, .notNull, .default("timezone('UTC', now())"))
builder.field(for: \.date, .default("timezone('UTC', now())"))
grundoon commented 5 years ago

As it's stored exactly the same as a .timestamp, with the offset calculation only occurring during retrieval when the session timezone is explicitly set (SET timezone = 'America/New_York';), it's just the same, no?

https://github.com/vapor/fluent-postgresql/blob/8e3eb9d24d54ac58c8d04c194ad6b24f0b1b667e/Tests/FluentPostgreSQLTests/FluentPostgreSQLTests.swift#L175