0

I'm reinstalling the paperclip gem but encountered an error when trying to run the migration. (Note: I only deleted the original migration file from text editor). Specifically, when I ran:

$ rake db:migrate

I encountered:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: duplicate column name: image_file_name: ALTER TABLE "pins" ADD "image_file_name" varchar
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:4:in `block in up'
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:3:in `up'
c:in `migrate'
ActiveRecord::StatementInvalid: SQLite3::SQLException: duplicate column name: image_file_name: ALTER TABLE "pins" ADD "image_file_name" varchar
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:4:in `block in up'
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:3:in `up'
c:in `migrate'
SQLite3::SQLException: duplicate column name: image_file_name
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:4:in `block in up'
c:/Users/Jaye/Desktop/inspireboard/db/migrate/20160929074428_add_attachment_image_to_pins.rb:3:in `up'
c:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

After seeing the above, I tried to run rake db:drop , but encountered:

Permission denied @ unlink_internal

Could anyone suggest how to work around this? (Note: I'm using Windows 8, rails 4.2.5.1, paperclip 4.3.7) Appreciate a lot!

CodeMonkey
  • 11
  • 1
  • 6
  • Possible duplicate of this questions : http://stackoverflow.com/questions/16860084/rails-rake-dbreset-not-clearing-my-database or http://stackoverflow.com/questions/38853634/no-permission-to-drop-sqlite3-development-database-rails-5-0-on-windows – Ajay Barot Sep 29 '16 at 10:18
  • Possible duplicate of [rails 5 db:reset not working](http://stackoverflow.com/questions/39182630/rails-5-dbreset-not-working) – Ajay Barot Sep 29 '16 at 10:19
  • Thanks! I've successfully run `rake db:reset` but still facing the same problem running `rake db:migrate`. Any ideas? – CodeMonkey Sep 29 '16 at 10:27
  • 1
    seems like you have multiple migrations for adding or renaming column image_file_name – sat's Sep 29 '16 at 10:44
  • @sat's yeah seems so... how could I do that action only once? Can I kill the previous migration to to achieve that? If you don't mind please take a look of my Github: [link](https://github.com/joker1023c/inspireboard) Thanks! – CodeMonkey Sep 29 '16 at 13:02

2 Answers2

0

Removing the development.sqlite3 file and rerun db:migrate solved the problem!

CodeMonkey
  • 11
  • 1
  • 6
0

Check if you close the Rails Server to run the rake db:drop. I was having the same issue, and then you reinstall the papperclip. I hope that I helped.