column "foo" referenced in foreign key constraint does not exist

i got an error when i migrating,
the error is this:
PostgresError: column "person_id" referenced in foreign key constraint does not exist

this is the query that throw error:
DO $$ BEGIN
 ALTER TABLE "story" ADD CONSTRAINT "story_person_id_person_id_fk" FOREIGN KEY ("person_id") REFERENCES "public"."person"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
 WHEN duplicate_object THEN null;
END $$;

you can see the schema in the reply.
Was this page helpful?