google 了错误,可是没有什么结果。 迁移代码
class CreateRelationships < ActiveRecord::Migration[5.0]
def change
create_table :relationships do |t|
t.integer :follower_id
t.integer :followed_id
t.timestamps
end
end
add_index :relationships, :follower_id
add_index :relationships, :followed_id
add_index :relationships, [:follower_id, :followed_id], unique: true
end
错误消息:
-- add_index(:relationships, :follower_id)
-- add_index(:relationships, :follower_id)
rails aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'blog_demo_development.relationships' doesn't exist: CREATE INDEX
index_relationships_on_follower_id
ONrelationships
(follower_id
)