DT
Drizzle Teamrphlmr ⚡

Check

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(",")})`
),
})
);
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
B
bloberenober407d ago
Looks correct @Andrii Sherman
AS
Andrii Sherman407d ago
Yeah, drizzle kit is not aware of any checks yet But we will add support for it Have in backlog Workaround to write them manually Same as you did with unique constraints
R
rphlmr ⚡407d ago
Haha sorry to be a deep source code reader 😂
B
bloberenober407d ago
you found an easter egg 🥚
Want results from more Discord servers?
Add your server
More Posts
cascadesI know you can add `.references()` to set up foreign keys in a table definition, but how do you set jsonb field definition.What's the right way to define a jsonb field? I have a type `type MetaData = {keywords?: string[];}"Extend" tables by other tablesHey all, first of all great work with drizzle. Haven't had the time to play around with it so far. Bmaximum call stack exceededWeird bug where whenever I add a `where` `eq` clause getting maximum call stack exceededDrizzle recommended way to migrate resetApologies if this is a stupid question, I just recently migrated out of prisma and into drizzle. Onecompound uniqueIndexIn Prisma, I have in my schema definition the following declaration that requires userId and timestaplanetscale: how to index col using drizzle?Hi, seems most of the samples are pg. I'm using planetscale, and no having any luck figuring out how[Bug?] Drizzle generates a broken query when passing an explicit value for a column as `undefined`I've translated most of my logic from Prisma usage -> Drizzle. Noticed an issue where when explicitlHelp improving my queryIf feel like this is far from how what it actually should look like in drizzle could I get some poinLeft join with JSONI'm using PlanetScale (MySQL) and have 2 tables: orders and products. Every order contains basic infDrizzle-kit throws module not found error for internal files imported through absolute pathI've attached the error log and how the error was fixed.drizzle bug won't let me update mysql tablewrote a bug ticket on github describing the bug but just wanted to post here as well for visibility Generated Collate valueNot sure if this is relevant but I'm translating a Prisma schema into drizzle. Every Prisma table haCan I know when I can use Mysql proxy driver?Hi, I’m Daun and I’m a huge fan of drizzle. i’m really grateful that drizzle is open source and haveMocking databaseI want to mock the PostgreSQL database and access it with Drizzle ORM. I tried to write a TypeScriptWhat does MySQL bigint config mode do?In a mysql schema, when creating a bigint, it wants a config object with a `mode` key where mode couMySQL unique constraintIn the drizzle schema, is there a way to label a column with unique constraint in mysql? I'm only seError querying planetscale dbTrying to get setup with drizzle and running into this error. There's not much info here so I'm not db push connection errorgetting the following error on my first db push attempt ``` Ignoring invalid configuration option paSelect existsHi there, I was wondering if there is currently a good way of performing a ‘select exists’, to chec