("storeId","orderId","entityId","integrationType","lineItemId","fulfillmentStatus","returnExpiryAt","processedAt","status","itemDetails","refNo","reason")VALUES (5,'ORD123456',987654321,'ascentis',123456,'shipped','2024-11-08 00:00:00','2024-10-08 12:00:00','completed','
{"productId": "PROD001", "quantity": 2}','REF001','Customer request');
ERROR: insert or update on table "fulfillments" violates foreign key constraint "FK_0ef27e70d555950c64685ce3f2c"
DETAIL: Key (storeId)=(5) is not present in table "stores". whether i need to create a stores first and the include the id it will resolve ?
Of course you have to have the foreign key value present in the linked table. Should PostgreSQL guess, you might add it later? Both inserts can be done in one transaction, or the transaction inserting the foreign key has to be finished before the insert into the other table starts, otherwise that new transaction doesn't have the data in the foreign table.
Обсуждают сегодня