As of 2023, it's not possible:

Check constraints are currently not included in the generated Prisma schema - however, the underlying database still enforces the constraints. https://www.prisma.io/docs/guides/other/advanced-database-tasks/data-validation/postgresql#2-adding-a-table-with-a-single-check-constraint-on-a-single-column

You'll have to create a custom migration: https://www.prisma.io/docs/guides/migrate/developing-with-prisma-migrate/customizing-migrations

Open issue to support CHECK: https://github.com/prisma/prisma/issues/3388

Answer from fafrd on Stack Overflow
🌐
Prisma
prisma.io › home › check constraints › check constraints › check constraints › check constraints › check constraints
Data validation with CHECK constraints (PostgreSQL) | Prisma Documentation
A check constraint is a condition that must be satisfied before a value can be saved to a table - for example, the discounted price of a product must always be less than the original price.
Discussions

Support SQL Check constraints
Right now we have no way of expressing SQL check constraints in our schema. We need a spec for this that we can implement in the future. More on github.com
🌐 github.com
83
December 3, 2019
Best practice for adding a check constraint in PostgresSQL?
If I use npx prisma migrate dev to generate the raw SQL migrations, but I want to add a custom check constraint as well, is it better to: Simply add the constraint to the bottom of the auto-generat... More on github.com
🌐 github.com
2
1
November 7, 2022
Do I need to check if a user is already in Postgresql db with prisma before adding them?
Depends on whether you have a unique constraint on for example the email address. If so, the db will throw an error on creation that you can catch. Otherwise it will just insert the duplicate. More on reddit.com
🌐 r/node
15
13
September 25, 2021
Enforce constraints on `Json` data (via JSON Schema and/or Check Constraints)
Problem The Json field is great for when you have data that might have a different schema, but the only problem so far is that you can't enforce any constraint on this data. Currently, MySQL ha... More on github.com
🌐 github.com
9
December 6, 2022
🌐
Wking
wking.dev › guides › how-to-add-a-check-constraint-in-prisma
How to add a check constraint in Prisma
December 20, 2022 - There is no native way in Prisma to set a check constriant in your schema file. This article will explain how to do it.
🌐
GitHub
github.com › prisma › prisma › issues › 3388
Support SQL Check constraints · Issue #3388 · prisma/prisma
December 3, 2019 - Right now we have no way of expressing SQL check constraints in our schema. We need a spec for this that we can implement in the future.
Author   prisma
🌐
Prisma
prisma.io › dataguide › postgresql › column-and-table-constraints
PostgreSQL Constraints: column and table | Prisma's Data Guide
If we still want to make sure we don't end up with duplicate entries while allowing for repeated values in individual columns, a unique check on the combination of country and capital would suffice: ... DETAIL: Key (country, capital)=(Bolivia, Sucre) already exists. ... If you are using Prisma, you can define a unique field in your Prisma schema. Prisma is an open-source database toolkit for Typescript and Node.js that aims to make app developers more productive and confident when working with databases. The PRIMARY KEY constraint serves a special purpose.
🌐
Tericcabrel
blog.tericcabrel.com › database-integrity-prisma-orm
Emulate database integrity constraints using the Prisma ORM
June 5, 2023 - To fix the issue, The Prisma engine has a built-in feature to handle integrity constraints at the application level. This means the database schema will not have the foreign keys constraint, and Prisma will manage it. If you want to create a task with a user ID that doesn't exists in the users' table, Prisma will check it and throw an error.
Find elsewhere
🌐
Prisma
prisma.io › dataguide › datamodeling › correctness-constraints
Correctness and Constraints | Data Modeling | Prisma's Data Guide
For example, a table storing geographic locations should CHECK (latitude >= -90 AND latitude < 90), and similarly for longitude between -180 and 180 -- or, if available, use and validate a GEOGRAPHY data type. Table-level constraints test tuples against each other.
🌐
PlanetScale
planetscale.com › docs › vitess › tutorials › prisma-best-practices
Prisma best practices - PlanetScale
March 30, 2026 - If you do not add the index, you ... of data. When you run prisma format or prisma validate, it will warn you about a missing index where you are using foreign key constraints. If you want to learn more about MySQL indexes, check out the MySQL for Developers course section ...
🌐
GitHub
github.com › prisma › prisma › issues › 16654
Enforce constraints on `Json` data (via JSON Schema and/or Check Constraints) · Issue #16654 · prisma/prisma
December 6, 2022 - The Json field is great for when you have data that might have a different schema, but the only problem so far is that you can't enforce any constraint on this data. Currently, MySQL has a native way of enforcing this with CHECK(JSON_SCHEMA_VALID(), _) function at table.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 17319
Add one-of-two not null constraint (via check constraint) · Issue #17319 · prisma/prisma
January 14, 2023 - constraint chk_price check (brandId is not null or retailerId is not null) Similarly to the @@unique multi-column constraint support that Prisma has, it'd be cool to have something like: @@notnull([brandId, retailerId]) which will ensure that ...
Author   prisma
🌐
Neon
neon.com › postgresql › postgresql-tutorial › postgresql-check-constraint
PostgreSQL CHECK Constraints
January 25, 2024 - You will learn how to use PostgreSQL CHECK constraints to ensure the data integrity of values in a column or a group of columns in a table.
🌐
Drizzle ORM
orm.drizzle.team › docs › indexes-constraints
Drizzle ORM - Indexes & Constraints
CREATE TABLE "user" ( "id" integer ... integer CONSTRAINT "custom_name" UNIQUE NULLS NOT DISTINCT ); The CHECK constraint is used to limit the value range that can be placed in a column....
🌐
ZenStack
zenstack.dev › blog › custom-attributes
How to Add Custom Attributes in Prisma | ZenStack
February 9, 2023 - https://github.com/prisma/prisma/issues/3102 · Also, the below-related issues: Support SQL Check constraints #3388 · Add exclude in the query arguments #5042 · Support adding prefix to an @id field #3391 · In the following content, I will show you two ways of adding custom attributes: Comments workaround by Prisma (You can skip this part if you already know) Custom attributes of ZenStack.
🌐
LogRocket
blog.logrocket.com › home › how to configure indexes in prisma
How to configure indexes in Prisma - LogRocket Blog
June 4, 2024 - This means that every @unique column gets an index assigned to it too. If we fancy it, we can use constraints to add indexes to SQL databases instead of using the @@index API. Let’s demonstrate how to configure indexes inside a SQLite database with Prisma.
🌐
Lightrun
lightrun.com › home › lightrun blog
Allow deferral of unique constraints using definitions in ...
November 6, 2025 - The Lightrun blog covers AI agent reliability, runtime truth, and what it takes to ship software that holds up in production