fdarian/prisma-generator-drizzle

Support for @updatedAt

Opened this issue · 0 comments

I use @updatedAt in my Prisma schema for many tables, currently the generator does not output equivalent Drizzle code:

Prisma schema:

model Example {
  id String @id

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Current generator output:

export const examples = pgTable(
  'Example',
  {
    id: text('id').primaryKey(),
    createdAt: timestamp('createdAt', { mode: 'date', precision: 3 })
      .defaultNow()
      .notNull(),
    updatedAt: timestamp('updatedAt', { mode: 'date', precision: 3 }).notNull(),
  }
)

Expected generator output:

export const examples = pgTable(
  'Example',
  {
    id: text('id').primaryKey(),
    createdAt: timestamp('createdAt', { mode: 'date', precision: 3 })
      .defaultNow()
      .notNull(),
    updatedAt: timestamp('updatedAt', { mode: 'date', precision: 3 })
      .notNull()
      .$onUpdate(() => new Date()),
  }
)