Respect default values in timestamps/dates
hilja opened this issue · 1 comments
hilja commented
Given a simple Prisma model:
model Bar {
foo String
createdAT DateTime @default(now())
}
It outputs something like:
import { pgTable, text, timestamp } from 'drizzle-orm/pg-core'
export const sites = pgTable('Bar', {
foo: text('foo').notNull(),
createdAT: timestamp('createdAT', { mode: 'date', precision: 3 }).notNull(),
})
Should it have a default value?
import { pgTable, text, timestamp } from 'drizzle-orm/pg-core'
export const sites = pgTable('Bar', {
foo: text('foo').notNull(),
createdAt: timestamp('createdAt', { mode: 'date', precision: 3 })
.defaultNow()
.notNull(),
})
Or default(sql`CURRENT_TIMESTAMP`)
. There seems to be some issues with it. Is it intentionally ambiguous?
hilja commented
It seems like .defaultNow()
will be deprecated in favor of .defaultCurrentTimeStamp()
, but it’s not implemented yet, so .default(sql`CURRENT_TIMESTAMP`)
is the way.