delete from "TaskFieldValues" where "EntityId" not in (select "Id" from "Task");
ALTER TABLE IF EXISTS public."TaskFieldValues"
    ADD CONSTRAINT "FK_TaskFieldValues_Task" FOREIGN KEY ("EntityId")
    REFERENCES public."Task" ("Id") MATCH SIMPLE
    ON UPDATE NO ACTION
    ON DELETE CASCADE;
	
CREATE INDEX IF NOT EXISTS "IX_TaskFieldValues_EntityId"
    ON public."TaskFieldValues"("EntityId");