rake db:migrateでerrorが発生します。
Ruby on Railsで自分のappに、お気に入りの機能を追加しようとclips modelを作り、
マイグレーションファイルを編集してrake db:migrateを実行したのですが、
StandardError: An error has occurred, this and all later migrations canceled: Index name 'index_clips_on_user_id' on table 'clips' already exists
というerrorが発生してしまいます。rake db:migrateをできるようにするにはどうしたらよいでしょうか。
schema.rb
ActiveRecord::Schema.define(version: 20170318163142) do
create_table "comments", force: :cascade do |t|
t.text "content"
t.integer "message_id"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["message_id"], name: "index_comments_on_message_id"
t.index ["user_id"], name: "index_comments_on_user_id"
end
create_table "messages", force: :cascade do |t|
t.string "title"
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
end
create_table "relationships", force: :cascade do |t|
t.integer "follower_id"
t.integer "following_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["follower_id", "following_id"], name: "index_relationships_on_follower_id_and_following_id", unique: true
t.index ["follower_id"], name: "index_relationships_on_follower_id"
t.index ["following_id"], name: "index_relationships_on_following_id"
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "username"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["username"], name: "index_users_on_username", unique: true
end
end
create_clips.rb
class CreateClips < ActiveRecord::Migration[5.0]
def change
create_table :clips do |t|
t.references :user, null:false
t.references :message, null:false
t.timestamps null: false
end
add_index :clips, :user_id
add_index :clips, :message_id
end
end