Skip to content

Instantly share code, notes, and snippets.

@zunda
Created June 7, 2017 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zunda/1945febe43bd51e04d22e465377d82d6 to your computer and use it in GitHub Desktop.
Save zunda/1945febe43bd51e04d22e465377d82d6 to your computer and use it in GitHub Desktop.
Failed migration from 7623766 to 0026ba2
StandardError: An error has occurred, this and all later migrations canceled:
PG::ForeignKeyViolation: ERROR: insert or update on table "statuses" violates foreign key constraint "fk_rails_94a6f70399"
DETAIL: Key (in_reply_to_id)=(14576) is not present in table "statuses".
: ALTER TABLE "statuses" ADD CONSTRAINT "fk_rails_94a6f70399"
FOREIGN KEY ("in_reply_to_id")
REFERENCES "statuses" ("id")
ON DELETE SET NULL
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Migrating to AddForeignKeysForAccounts (20170604144747)
== 20170604144747 AddForeignKeysForAccounts: migrating ========================
-- add_foreign_key(:statuses, :accounts, {:on_delete=>:cascade})
-> 0.0892s
-- add_foreign_key(:statuses, :accounts, {:column=>:in_reply_to_account_id, :on_delete=>:nullify})
-> 0.0199s
-- add_foreign_key(:statuses, :statuses, {:column=>:in_reply_to_id, :on_delete=>:nullify})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment