Check

Hello there, from this discussion: BUG: Postgres migration script generates a few syntax errors

Is it the way to add check constraint?

const companySize = ["tpe", "pme", "eti", "ge"] as const;

export const Company = pgTable(
  "company",
  {
    id: uuid("id").defaultRandom().primaryKey(),
    companySize: text("company_size", { enum: [...companySize] }).notNull()
  },
  (Company) => ({
    onlyTheseSize: check(
      "only_these_size",
      sql`${Company.companySize} in(${companySize.join(",")})`
    ),
  })
);


It produces nothing in the generated migration 🧐

drizzle-kit: v0.17.4
drizzle-orm: v0.23.5
Was this page helpful?