drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: Add check support in drizzle-kit

Open AndriiSherman opened this issue 2 years ago • 26 comments
trafficstars

Describe what you want

This issue is a part of https://github.com/drizzle-team/drizzle-orm/issues/229

AndriiSherman avatar Jul 11 '23 22:07 AndriiSherman

+1 to CHECK support.

SebastianGarces avatar Jul 25 '23 18:07 SebastianGarces

+1 to Check support.

dcchrispen avatar Jul 25 '23 18:07 dcchrispen

checks would be great, i need it for my code

nairol203 avatar Jul 29 '23 18:07 nairol203

+1 to CHECK support

harrispap03 avatar Sep 07 '23 06:09 harrispap03

+1

itsyoboieltr avatar Sep 21 '23 21:09 itsyoboieltr

any update for this feature? Check constraint is one of the core feature of any RDBMS. It should be implemented with higher priority.

md-redwan-hossain avatar Oct 16 '23 16:10 md-redwan-hossain

Is there a workaround for this with Drizzle's sql operator ?

efkann avatar Oct 16 '23 21:10 efkann

Ditto what @efkann said. Is there a workaround with the sql method?

arxpoetica avatar Nov 01 '23 03:11 arxpoetica

@efkann @arxpoetica I found a workaround when defining a default. It may not work for all use cases but it's working for me.

schema:

export const exampleTable = schema.table('example_table', {
  // ... other columns not included
  status: text('status', {
    enum: ['pending', 'active', 'suspended', 'archived'],
  })
    .notNull()
    // HACK: Drizzle does not yet support check constraints as of writing this
    .default(
      sql`'pending' CHECK (status IN ('pending', 'active', 'suspended', 'archived'))`,
    ),
});

generates:

CREATE TABLE IF NOT EXISTS "my_schema"."example_table" (
	"status" text DEFAULT 'pending' CHECK (status IN ('pending', 'active', 'suspended', 'archived')) NOT NULL
);

austincm avatar Nov 16 '23 17:11 austincm

💎 $20 bounty created by @rvaidun 👉 To claim this bounty, submit your pull request on Algora 📝 Before proceeding, please make sure you can receive payouts in your country 💵 Payment arrives in your account 2-5 days after the bounty is rewarded 💯 You keep 100% of the bounty award 🙏 Thank you for contributing to drizzle-team/drizzle-orm!

algora-pbc avatar Dec 04 '23 19:12 algora-pbc

/attempt #880

nermalcat69 avatar Dec 07 '23 14:12 nermalcat69

@rvaidun, @AndriiSherman before giving my effort to it, can you please let me know if you can assign it to me?

anshumanjaiswal avatar Dec 07 '23 19:12 anshumanjaiswal

+1000 for this

hckhanh avatar Dec 27 '23 14:12 hckhanh

any updates? 👀

davidaragundy avatar May 02 '24 17:05 davidaragundy

+1 +1 +1 +1

laurent512 avatar May 27 '24 18:05 laurent512

Is there any update on this?

raiyansarker avatar Jul 06 '24 05:07 raiyansarker

+2392394

ghyath5 avatar Jul 16 '24 12:07 ghyath5

+2024

xuxucode avatar Jul 17 '24 09:07 xuxucode

+10086

feng-derivio avatar Aug 06 '24 04:08 feng-derivio

+2028812

qhkm avatar Aug 16 '24 07:08 qhkm

+111

TFaesen avatar Aug 20 '24 14:08 TFaesen

+9999999999

qhkm avatar Sep 07 '24 02:09 qhkm

SimCall avatar Sep 10 '24 12:09 SimCall

If one more person posts a +1 instead of clicking the 👍 reaction I will cry

april83c avatar Sep 14 '24 11:09 april83c

+0.1

schndra avatar Sep 17 '24 10:09 schndra

+1

yas1nshah avatar Sep 21 '24 17:09 yas1nshah

+1

Senbonzakura1234 avatar Oct 13 '24 07:10 Senbonzakura1234

Available in [email protected] and [email protected]

AndriiSherman avatar Oct 15 '24 19:10 AndriiSherman