Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

devise

https://qiita.com/ryokky59/items/71b5a853989721b89c6e

asatokensei@MacBook-Air tomalog % rake db:migrate:reset                              
Dropped database 'tomalog_development'
Dropped database 'tomalog_test'
Created database 'tomalog_development'
Created database 'tomalog_test'
== 20200618130702 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0134s
== 20200618130702 CreateUsers: migrated (0.0135s) =============================

== 20200619021757 AddPasswordDigestToUsers: migrating =========================
-- add_column(:users, :password_digest, :string)
   -> 0.0183s
== 20200619021757 AddPasswordDigestToUsers: migrated (0.0184s) ================

== 20200620002508 AddRememberDigestToUsers: migrating =========================
-- add_column(:users, :remember_digest, :string)
   -> 0.0151s
== 20200620002508 AddRememberDigestToUsers: migrated (0.0151s) ================

== 20200620101945 AddAdminToUsers: migrating ==================================
-- add_column(:users, :admin, :boolean)
   -> 0.0144s
== 20200620101945 AddAdminToUsers: migrated (0.0145s) =========================

== 20200621004334 CreatePosts: migrating ======================================
-- create_table(:posts)
   -> 0.0114s
-- add_index(:posts, [:user_id, :created_at])
   -> 0.0146s
== 20200621004334 CreatePosts: migrated (0.0261s) =============================

== 20200621124425 AddImageToPosts: migrating ==================================
-- add_column(:posts, :image, :string)
   -> 0.0155s
== 20200621124425 AddImageToPosts: migrated (0.0157s) =========================

== 20200624083831 AddDeviseToUsers: migrating =================================
-- change_table(:users)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Duplicate column name 'email': ALTER TABLE `users` ADD `email` varchar(255) DEFAULT '' NOT NULL
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:7:in `block in up'
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:5:in `up'

Caused by:
ActiveRecord::StatementInvalid: Mysql2::Error: Duplicate column name 'email': ALTER TABLE `users` ADD `email` varchar(255) DEFAULT '' NOT NULL
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:7:in `block in up'
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:5:in `up'

Caused by:
Mysql2::Error: Duplicate column name 'email'
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:7:in `block in up'
/Users/asatokensei/tomalog/db/migrate/20200624083831_add_devise_to_users.rb:5:in `up'
Tasks: TOP => db:migrate:reset => db:migrate
(See full trace by running task with --trace)

https://qiita.com/ktganao/items/4079e3d05d322febe00e

スクリーンショット 2020-06-24 18.19.53.png

has_secure_password
asatokensei@MacBook-Air tomalog % rake db:migrate:reset
Dropped database 'tomalog_development'
Dropped database 'tomalog_test'
Created database 'tomalog_development'
Created database 'tomalog_test'
== 20200618130702 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0141s
== 20200618130702 CreateUsers: migrated (0.0141s) =============================

== 20200619021757 AddPasswordDigestToUsers: migrating =========================
-- add_column(:users, :password_digest, :string)
   -> 0.0205s
== 20200619021757 AddPasswordDigestToUsers: migrated (0.0207s) ================

== 20200620002508 AddRememberDigestToUsers: migrating =========================
-- add_column(:users, :remember_digest, :string)
   -> 0.0179s
== 20200620002508 AddRememberDigestToUsers: migrated (0.0180s) ================

== 20200620101945 AddAdminToUsers: migrating ==================================
-- add_column(:users, :admin, :boolean)
   -> 0.0184s
== 20200620101945 AddAdminToUsers: migrated (0.0185s) =========================

== 20200621004334 CreatePosts: migrating ======================================
-- create_table(:posts)
   -> 0.0134s
-- add_index(:posts, [:user_id, :created_at])
   -> 0.0156s
== 20200621004334 CreatePosts: migrated (0.0291s) =============================

== 20200621124425 AddImageToPosts: migrating ==================================
-- add_column(:posts, :image, :string)
   -> 0.0155s
== 20200621124425 AddImageToPosts: migrated (0.0156s) =========================

== 20200624083831 AddDeviseToUsers: migrating =================================
-- change_table(:users)
   -> 0.0761s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0127s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0126s
== 20200624083831 AddDeviseToUsers: migrated (0.1018s) ========================

https://qiita.com/miyazaki_yusuke/items/bcf6ecce829a5ebdb374

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away