new row for relation "table_name" violates check constraint "constraint_name"
SQLSTATE 23514 is check_violation. The proposed row failed a CHECK expression, such as an allowed status, a positive amount, or an ordering rule between dates. The constraint name identifies the rule, but the failing value may depend on several columns or a transformation performed before storage.
new row for relation "table_name" violates check constraint "constraint_name"
Why it happens
A value falls outside a permitted range or set, including boundary values such as zero or a newly introduced status.
Individually valid fields violate a rule when combined, such as an end date that precedes the start date.
Application validation differs from the deployed constraint, or a default, trigger, type conversion, or referenced function changes the value being checked.
How to fix it
Inspect the actual rule rather than guessing from its name. For a table constraint, adapt this read-only query: SELECT conname, pg_get_constraintdef(oid) FROM pg_constraint WHERE conrelid = 'public.orders'::regclass AND contype = 'c'; Replace the example table with the schema-qualified target.
Compare the rejected row with every column used by that expression. Reproduce with a small non-sensitive fixture and test values immediately below, at, and above the relevant boundary, including NULL where the model permits it.
Correct the source value or transformation when the database rule is right. CHECK expressions reject false, while a null result passes; a separate NOT NULL requirement is needed when missing data must also be rejected.
If a legitimate product change made the rule obsolete, review existing data and update application validation and the constraint through a planned migration. Changing a function used in a CHECK also deserves validation of existing rows.
Recover the failed transaction before resubmitting. Do not drop the rule or disable validation just to complete an import. Cross-row or cross-table invariants usually need an appropriate unique, foreign-key, or exclusion constraint rather than a CHECK that queries other rows.