1

I'm new to ruby. I got this error

 bundle exec rake db:migrate

== 20150423205259 AddActivationToUsers: migrating =============================
-- add_column(:users, :activation_digest, :string)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: duplicate column name: activation_digest: ALTER TABLE "users" ADD "activation_digest" varchar/home/myusername/.rvm/gems/ruby-2.2.0/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `initialize'

and it was solved when I run rake db:migrate VERSION=0 If I really have duplicate column name how does rake db:migrate VERSION=0 solve it? And if not why did I get that error?

Hanna
  • 539
  • 2
  • 9
  • 24
  • 1
    It is good described in [`Active Record Migrations`](http://edgeguides.rubyonrails.org/active_record_migrations.html) – Roman Kiselenko Apr 30 '15 at 07:56
  • OK but why did I get that error? I checked my schema and there wasn't any problem there. – Hanna Apr 30 '15 at 08:14
  • Post your migration file –  Apr 30 '15 at 08:17
  • @user1181065 just for your future question. __Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.__ – Roman Kiselenko Apr 30 '15 at 08:19

1 Answers1

2

It basically runs the very first migration. You can specify any version number you want to migrate your database to.

You probably did "rails generate model ...." twice on the same model, but didn't destroy one of those migrations, it still exists in the "db/migrate/" folder.

I suggest you read a bit about migrations here.

sprungl
  • 76
  • 5