我使用下面的迁移文件bundle exec rake db:migrate
。
在终端上它看起来像这样成功了
== AddIndexToCommunity: migrating ============================================
-- add_index(:communities, [:community_name, :title, :user_id], {:name=>:communities_idx})
-> 0.0452s
== AddIndexToCommunity: migrated (0.0456s) ===================================
但是,如果我查看phpMyAdmin的Structure部分,它将不会显示此迁移生成的索引。
为什么呢?
迁移文件
class AddIndexToCommunity < ActiveRecord::Migration
def self.up
add_index :communities, [:community_name, :title, :user_id], :name=>:communities_idx
end
def self.down
remove_index :communities, [:community_name, :title, :user_id], :name=>:communities_idx
end
end