E
E
EgorVorozhtsov2014-11-07 11:55:06
PostgreSQL
EgorVorozhtsov, 2014-11-07 11:55:06

How to fix Referential Integrity Violation Error in CakePHP?

There are two tables: users (id, ....) and logs (id, user_id, ...).
Logs has a referential integrity constraint:

FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT

Inside the transaction, I create an entry in users, then in logs, putting the user_id of the "freshly created" user there. In this case, a foreign key violation error occurs, with a message that there is no entry in users for the specified user_id, although there is an entry when fetching with find().
Please tell me how can this be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question