我做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