I have this table:
CREATE TABLE operation_history
(
id bigserial NOT NULL,
task_history bigint NOT NULL,
operation smallint NOT NULL,
CONSTRAINT operation_history_pkey PRIMARY KEY (id),
CONSTRAINT operation_history_operation_fkey FOREIGN KEY (operation)
REFERENCES desktop_operation (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT operation_history_task_history FOREIGN KEY (task_history)
REFERENCES task_history (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
and I have a another table task_history that has three rows in it, with the ids: 1, 2, 3. For some reason, though, when I insert on the operation_history table, I get an error saying that the task_history row doesn't exist with the id I gave it. Here is the query to insert:
INSERT INTO operation_history (task_history, operation) VALUES
(1, 2);
And here is the error:
ERROR: insert or update on table "operation_history" violates foreign key constraint "operation_history_task_history"
DETAIL: Key (task_history)=(1) is not present in table "task_history".
I know for sure, though, that there are three rows in the task_history table with ids 1, 2, and 3.
What could be causing this and how can I remedy it?