Project

General

Profile

Actions

Bug #28152

closed

PG::ForeignKeyViolation when trying to add a relation to deleted users

Added by Evgeni Golov over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Found in Releases:

Description

The migration added in https://projects.theforeman.org/issues/21083 / https://github.com/theforeman/foreman-tasks/pull/364 fails when migrating a task that references a (now) not existing user:

[DEBUG 2019-10-30T11:03:33 main] PG::ForeignKeyViolation: ERROR:  insert or update on table "foreman_tasks_tasks" violates foreign key constraint "fk_rails_a56904dd86" 
[DEBUG 2019-10-30T11:03:33 main] DETAIL:  Key (user_id)=(10) is not present in table "users".
[DEBUG 2019-10-30T11:03:33 main] : UPDATE "foreman_tasks_tasks" SET "user_id" = 10 WHERE "foreman_tasks_tasks"."id" IN (SELECT "foreman_tasks_tasks"."id" FROM "foreman_tasks_tasks" INNER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id" WHERE "foreman_tasks_tasks"."id" IN (SELECT "foreman_tasks_locks"."task_id" FROM "foreman_tasks_locks" WHERE "foreman_tasks_locks"."name" = $1 AND "foreman_tasks_locks"."resource_id" = $2))

Related issues 1 (0 open1 closed)

Related to foreman-tasks - Refactor #21083: Use explicit relation for task -> user associationClosedAdam RuzickaActions
Actions

Also available in: Atom PDF