Check

Rrphlmr4/5/2023
Hello there, from this discussion: https://discord.com/channels/1043890932593987624/1090486363251544124/1093092996200796200

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
Bbloberenober4/5/2023
Looks correct
Bbloberenober4/5/2023
@Andrii Sherman
ASAndrii Sherman4/5/2023
Yeah, drizzle kit is not aware of any checks yet
ASAndrii Sherman4/5/2023
But we will add support for it
ASAndrii Sherman4/5/2023
Have in backlog
ASAndrii Sherman4/5/2023
Workaround to write them manually
ASAndrii Sherman4/5/2023
Same as you did with unique constraints
Rrphlmr4/5/2023
Haha sorry to be a deep source code reader 😂
Bbloberenober4/5/2023
you found an easter egg 🥚