23503

מה אומרת שגיאת Postgres ‏(מסד הנתונים) הזאת

איך זה מופיע

insert or update on table "<table>" violates foreign key constraint "<constraint_name>"

מה זה אומר

SQLSTATE 23503 is foreign_key_violation: the row points at a row in another table that does not exist, or a delete would leave other rows pointing at nothing.

הסיבה הנפוצה באפליקציה שנבנתה עם AI

AI-built apps often insert a row with a user_id or parent id before the row it points to exists, for example saving a post for a user whose profile row was never created.

בדקו את זה קודם

Take the id value your insert sends for the foreign key column and check that a row with that exact id exists in the table the constraint points to.

עוד קודים של Postgres ‏(מסד הנתונים)