문제

I installed paperclip 2.7 using gem install. I did rails generate paperclip user photo. and then tried migrate the db. But it gave me an error. SQLite3::SQLException: duplicate column name: photo_file_name: ALTER TABLE "users" ADD "photo_file_name" varchar(255)

I read somewhere that I should do delete the development.rb and then do db:create and them migrate again. But that didn't work either. When I did db:create it said already exists. So...I ended up reverting back to my old commit hoping to start again. But when I do db:reset. it tell me i have two migrations left. These two migrations are from rails generate paperclip user photo. What do I do now? How am I to get this to work?

도움이 되었습니까?

해결책

if you don't have any data that is important and needs to be saved you can simply drop the db and migrate it all the way back up:

rake db:drop

rake db:create

rake db:migrate

다른 팁

Run a migration removing photo_file_name, thus:

def change
  change_table :users do |t|
    t.remove :photo_file_name
  end
end

And start again.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top