Ruby on Railsを使ってTwitterのようなサイトを作ろうとしているのですがユーザーページを作ろうとしてプロフィール画像のカラムを作ろうとすると以下のようなエラーが出てしまいます。
入力したコード
$ rails g migration AddProfilePhotoToUsers profile_photo:string $ rails db:migrate
エラー
== 20191203111012 AddProfilePhotoToUsers: migrating =========================== -- add_column(:users, :profile_photo, :string) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: duplicate column name: profile_photo: ALTER TABLE "users" ADD "profile_photo" varchar /Users/pcname/Twitter/db/migrate/20191203111012_add_profile_photo_to_users.rb:3:in `change' /Users/pcname/Twitter/bin/rails:9:in `<top (required)>' /Users/pcname/Twitter/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Caused by: ActiveRecord::StatementInvalid: SQLite3::SQLException: duplicate column name: profile_photo: ALTER TABLE "users" ADD "profile_photo" varchar /Users/pcname/Twitter/db/migrate/20191203111012_add_profile_photo_to_users.rb:3:in `change' /Users/pcname/Twitter/bin/rails:9:in `<top (required)>' /Users/pcname/Twitter/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Caused by: SQLite3::SQLException: duplicate column name: profile_photo /Users/pcname/Twitter/db/migrate/20191203111012_add_profile_photo_to_users.rb:3:in `change' /Users/pcname/Twitter/bin/rails:9:in `<top (required)>' /Users/pcname/Twitter/bin/spring:15:in `<top (required)>' bin/rails:3:in `load' bin/rails:3:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。