Closed hilja closed 5 months ago
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?
default(sql`CURRENT_TIMESTAMP`)
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.
.defaultNow()
.defaultCurrentTimeStamp()
.default(sql`CURRENT_TIMESTAMP`)
Given a simple Prisma model:
It outputs something like:
Should it have a default value?
Or
default(sql`CURRENT_TIMESTAMP`)
. There seems to be some issues with it. Is it intentionally ambiguous?