Seaquel
PostgreSQL error code

PostgreSQL error 23001

23001 is the SQLSTATE PostgreSQL reports for restrict violation, in class 23, Integrity Constraint Violation.

SQLSTATE23001
Condition namerestrict_violation
Class23 — Integrity Constraint Violation

Reproduce it, then fix it

The foreign key says ON DELETE RESTRICT, so an author with books can’t be deleted. Delete or reassign the books first. A foreign key with the default NO ACTION reports 23503 instead. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

DELETE FROM authors WHERE id = 1;
DELETE FROM books WHERE author_id = 1;
DELETE FROM authors WHERE id = 1 RETURNING *;

Source: PostgreSQL documentation, Appendix A