App Finishers

Fix guide · updated 2026-11-16

Supabase "new row for relation … violates check constraint" (23514)

{"code":"23514","details":null,"hint":null,"message":"new row for relation \"orders\" violates check constraint \"orders_status_check\""}

An insert or update from your app fails with "new row for relation "orders" violates check constraint "orders_status_check"", code 23514, HTTP 400. A check rule on the table refused the row, and the message names the table and the rule. We reproduced the usual ways it happens with the request code of supabase-js (postgrest-js 2.119) against Postgres 16 and Supabase's Data API (PostgREST 13), November 2026.

What the error means

A check constraint is a rule the database tests on every row it writes, such as "status is one of pending, paid, shipped, cancelled" or "amount is above 0". When the new row breaks the rule, nothing is written.

The last name in the message is the rule. A rule written on one column is named after the table and the column: orders_status_check is the rule on orders.status. A rule written for the whole table keeps the name it was given, such as sale_below_price. The one-minute check below shows what any rule says.

On most Supabase tables, row level security (RLS) is on, and then the error's details are empty. With the service role key, or on a table without RLS, they show the whole row: "Failing row contains (8, 11111111-…, Paid, 10)." Keep details out of messages your users see: it lists every value in the row.

If the row also breaks your RLS policy, you get "new row violates row-level security policy" (HTTP 403) instead. In our test, the policy check came first. See Supabase RLS: "new row violates row-level security policy".

Cause 1: a value that isn't on the allowed list

AI tools often write a status column as a list of allowed words, and the list is exact, capitals included. In our test, with the list pending, paid, shipped, cancelled, the values 'Paid', 'PAID' and 'completed' all failed on orders_status_check, in an insert, an update and an upsert alike. The usual story: the screen shows "Paid" and sends it as it is, or a new status such as "refunded" was added to the app but never to the database.

Cause 2: a number or a length out of range

Rules like amount > 0, age >= 13 or char_length(username) between 3 and 20 fail on the edge cases. In our test, amount: 0, age: 12, a two-letter username and an empty string '' were all refused. Numbers sent as text, like '12' from a form field, are converted first and then checked the same way.

Cause 3: a rule between two columns

A rule can compare columns, such as "the sale price is below the price". Then changing one column can break it. In our test, a product had price 10 and sale price 8, and update({ price: 5 }) failed on sale_below_price, though the update never touched the sale price.

Cause 4: the rule is on the column's type

If the message reads "value for domain email_address violates check constraint "email_address_check"", the rule sits on a custom type (a domain) that the column uses, not on the table. In our test, insert({ email: 'bob@' }) got that message, code 23514, HTTP 400. The table's own rules don't include it; the second query in the one-minute check finds it.

Cause 5: a new rule over old rows

This one comes from a migration or the SQL Editor, not from your app: "check constraint "amount_cap" of relation "orders" is violated by some row", also code 23514. A rule added with alter table … add constraint is tested against every row already in the table, and an old row broke it, so nothing changed. Fix 4 adds the rule anyway and deals with the old rows after.

Two things that surprise people

The one-minute check

Note the table and the rule's name in the message. Then, in the SQL Editor, list the table's rules:

select conname, pg_get_constraintdef(oid)
from pg_constraint
where conrelid = 'public.orders'::regclass and contype = 'c';

In our test it printed CHECK ((status = ANY (ARRAY['pending'::text, 'paid'::text, …]))) for orders_status_check: the allowed words, exactly as the database compares them. For a rule on a domain:

select conname, pg_get_constraintdef(oid)
from pg_constraint
where contypid = 'public.email_address'::regtype;

Then open the failing request in your browser's Network tab and compare its body with the rule: a capital letter, a zero, a name that's too short, or a column the update changed.

Fix 1: send a value the rule allows

If the rule is right, fix what the app sends. Show a label on screen and send the stored word:

<select name="status">
  <option value="paid">Paid</option>
  <option value="shipped">Shipped</option>
</select>

Check the same rule in the form before saving, and catch the code, so a refused save shows a clear message instead of failing quietly:

const { error } = await supabase.from('orders').insert(order);
if (error?.code === '23514') {
  // error.message names the rule, e.g. orders_status_check
  showError("Some values aren't allowed. Check the status and the amount.");
}

Fix 2: update the rule when the app is right

If "refunded" is a real status now, add it to the rule. Drop and re-add the rule in one statement:

alter table public.orders
  drop constraint orders_status_check,
  add constraint orders_status_check
    check (status in ('pending', 'paid', 'shipped', 'cancelled', 'refunded'));

In our test, the update to 'refunded' that had failed went through afterwards. Put the change in a migration, so every copy of your database gets it.

Fix 3: change linked columns together

For a rule between columns, send both values in the same update, so the row is valid once it's written:

await supabase.from('products').update({ price: 5, sale_price: 4 }).eq('id', id);

In our test, this update went through where update({ price: 5 }) alone had failed.

Fix 4: add a rule to a table that has old rows

Add it with not valid: new and changed rows are checked at once, old rows are left alone. Then find the old rows that break it, fix them, and validate:

alter table public.orders add constraint amount_cap check (amount < 1000) not valid;

select id, amount from public.orders where not (amount < 1000);

alter table public.orders validate constraint amount_cap;

In our test, the rule went in with not valid, a new row over the cap was refused at once, the old row stayed, and validate failed with "is violated by some row" until the old row was fixed.

Fix 5: require a value as well

A check doesn't stop empty values. If the amount must be there, add not null too. Fill the empty rows first with the right value for your data, or the change fails with "column "amount" of relation "orders" contains null values" (23502):

update public.orders set amount = 1 where amount is null;
alter table public.orders alter column amount set not null;

In our test, an insert with an empty amount then failed with 23502, the not-null error: Supabase "null value in column … violates not-null constraint" (23502).

If an AI tool built your app

Give your AI tool this prompt, with the table and the rule from your error:

My Supabase insert fails with "new row for relation "orders" violates check constraint "orders_status_check"" (23514). Show me that rule's definition from the migrations or pg_constraint. Then find every insert, update and upsert on that table and compare what each one sends with the rule: exact words and capitals for allowed lists, ranges and lengths, and rules between two columns. If the app is right and the rule is out of date, write a migration that drops and re-adds the rule in one alter table statement. If the rule is right, change what the app sends, check the same rule in the form, and show a clear message when error.code is '23514'. Show me each change before making it.

Not quite your error?

Still stuck?

Copy the request body from the Network tab and try the same insert in the SQL Editor with those values. Change one value at a time until the row goes in: the last one you changed is the one that broke the rule.

Other Supabase problems? See Supabase fixes.