When I tried rails db:migrate
, I got an error.
What should I do?
Please let me know.
==20180629092541 AddActivationToUsers:migrating=============================
-- add_column(:users,:activation_digest,:string)
rails aborted!
StandardError: Error has occurred, this and all later migrations cancelled:
SQLite3::SQLException: duplicate column name:activation_digest:ALTER TABLE"users"ADD"activation_digest"varchar
C:/Users/sk/programming/sample_app/db/migrate/20180629092541_add_activation_to_users.rb:3:in change'
bin/rails:4:in require'
bin/rails:4:in `<main>'
Caused by: ActiveRecord::StatementInvalid:SQLite3::SQLException:duplicate column name:activation_digest:ALTER TABLE"users"ADD"activation_digest"varchar C:/Users/sk/programming/sample_app/db/migrate/201806290941_addest:activation_activators:together:
bin/rails:4:in require'bin/rails:4:in`<main>'
Caused by:
SQLite3::SQLException: duplicate column name:activation_digest
C:/Users/sk/programming/sample_app/db/migrate/20180629092541_add_activation_to_users.rb:3:in change'
bin/rails:4:in require'
bin/rails:4:in `<main>'
Tasks: TOP=>db:migrate
(See full trace by running task with --trace)
Code for C:/Users/sk/programming/sample_app/db/migrate/20180629092541_add_activation_to_users.rb
class AddActivationToUsers <ActiveRecord::Migration [5.1]
def change
add_column:users,:activation_digest,:string
add_column:users,:activated,:boolean, default:false
add_column:users,:activated_at,:datetime
end
end
duplicate column name: activation_digest
so the column activation_digest
already exists and failed.
Check to see if the column already exists.
Also, if you want to migrate from the beginning, you can execute rakedb:reset
to delete all the tables, reset them, and then migrate them.
© 2024 OneMinuteCode. All rights reserved.