Reputation: 808
I'm trying to figure out how to run a migration that adds the B-Tree index type to an index.
I tried running rails g migration add_index_to_recipes
which gave me an empty migration:
class AddIndexToRecipes < ActiveRecord::Migration[5.0]
def change
end
end
then I modified the migration like so:
class AddIndexToRecipes < ActiveRecord::Migration[5.0]
def change
add_column :recipes, :user_id, :integer
add_index :recipes, :user_id, using: :btree
end
end
Then I ran rails db:migrate
but in the schema there is still no index type.
The migration ran fine but my schema still looks like this:
create_table "recipes", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.index ["user_id"], name: "index_recipes_on_user_id"
end
I want it to look like this:
create_table "recipes", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.index ["user_id"], name: "index_recipes_on_user_id", using: :btree
end
Similar questions have been asked here, but so far I've been unable to come up with a solution.
What am I missing?
Upvotes: 3
Views: 3399
Reputation: 556
I'm sure you've already figured this out, but for others finding their way here, this appears to be dropped from the schema generation due to redundancy - https://github.com/rails/rails/pull/27981
Hope this helps.
Upvotes: 2