đây là di cư của tôi ở đường ray 3.2.2:ray 3.2 di cư không thể thêm chỉ số để create_table trong phương pháp thay đổi
class CreateStatistics < ActiveRecord::Migration
def change
create_table :statistics do |t|
t.string :name
t.integer :item_id
t.integer :value
t.text :desc
t.timestamps
t.index [:name, :item_id]
end
end
end
và đây là lỗi di chuyển:
== CreateStatistics: migrating ===============================================
-- create_table(:statistics)
ActiveRecord::ConnectionAdapters::TableDefinition
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `index' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0xbd16888>
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
đúng cách là những gì để tạo chỉ mục?
Lưu ý nhanh: @ Câu trả lời của Brandan ở đây là" righter "hơn injeckt's for the Rails 3 di chuyển kiểu cho phép 'thay đổi' phương thức thay vì phương thức' up' và 'down' kiểu cũ. Cả hai đều tốt, nó chỉ mất một phút để nhận ra sự khác biệt. –