drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.72k stars 653 forks source link

[FEATURE]: postgres: deferrable constraints #1429

Open ari-becker opened 1 year ago

ari-becker commented 1 year ago

Describe what you want

https://www.postgresql.org/docs/16/sql-createtable.html#SQL-CREATETABLE-PARMS-DEFERRABLE

I'm looking for something along the lines of:

export const foo = pgTable("foo",
  {
    name: text("name").notNull(),
  },
  (foo) => ({
    uniqueName: unique("name_unique", {deferrable: true, initially: "immediate"}).on(foo.name),
  }),
) satisfies PgTable;
edgars-sirokovs commented 12 months ago

Also, currently drizzle-kit generate:pg is generating a new migration to DROP the CONSTRAINTs and re-CREATE them without the DEFERRABLE in case they are actually marked as deferrable in the DB. Should I register a bug for that?

binnodon commented 9 months ago

Would this feature include DEFERRABLE on ALL constraints? I'm especially looking for deferrable foreign key constraints.

SiNONiMiTY commented 2 weeks ago

Bumping this issue, this is achievable in the schema instead of manually editing the generated SQL files

qimmer commented 4 days ago

Bumping, same issue here.