Skip to content

Instantly share code, notes, and snippets.

@prakashmurthy
Last active October 28, 2015 17:47
Show Gist options
  • Save prakashmurthy/8c7899f056b21386a39a to your computer and use it in GitHub Desktop.
Save prakashmurthy/8c7899f056b21386a39a to your computer and use it in GitHub Desktop.
add_foreign_key inconsistent behavior

add_foreign_key seems to be behaving inconsistently when it is called with rake db:rollback.

When called from rake db:migrate, a custom name built with table name & column name is used for the index name. When called from rake db:rollback, the name used for the index is a generic one.

Here is the diff from the above behavior in my db/schema.rb file:

-  add_index "line_items", ["location_id"], name: "index_line_items_on_location_id", using: :btree
+  add_index "line_items", ["location_id"], name: "fk_rails_4335959382", using: :btree

rails version: 4.2.0 ruby version: 2.2.0p0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment