前提・実現したいこと
プログラミング初学者です。
対応策について色々調べましたが、解決できず。
どなたかお力をお貸しいただけますと助かります。。。
① heroku create ○○
② git push heroku master
上記までは、問題なく進んでいたのですが、
heroku run rails db:migrateにて、エラーが発生してしまいました。
発生している問題・エラーメッセージ
エラーメッセージ rails aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::UndefinedColumn: ERROR: column "confirmation_token" does not exist : CREATE UNIQUE INDEX "index_users_on_confirmation_token" ON "users" ("confirmation_token") /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `async_exec' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:75:in `block (2 levels) in execute' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:74:in `block in execute' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:73:in `execute' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:466:in `add_index' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:871:in `block in method_missing' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:840:in `block in say_with_time' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:840:in `say_with_time' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:860:in `method_missing' /app/db/migrate/20200315234553_devise_create_users.rb:41:in `change' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:814:in `exec_migration' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:798:in `block (2 levels) in migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:797:in `block in migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:796:in `migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:977:in `migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1343:in `block in ddl_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/transactions.rb:212:in `transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1343:in `ddl_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1263:in `block in migrate_without_lock' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `each' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1262:in `migrate_without_lock' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `block in migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1363:in `with_advisory_lock' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1210:in `migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1036:in `up' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/migration.rb:1011:in `migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /app/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.1/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>' /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:20:in `perform' /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/command.rb:48:in `invoke' /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/commands.rb:18:in `<main>' /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency' /app/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require' /app/bin/rails:9:in `<main>' [以下略] /app/bin/rails:9:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace) ```ここに言語名を入力 ■私の環境 Rails 5.2.4.1 ruby 2.6.5p114 ソースコード
試したこと
heroku rake db:migrate:statusで確認したところ、
deviseで作成した、Userモデルとそのモデルに紐づいているものだけがdownしていることが分かりました。
[実行結果]
down 20200315234553 Devise create users
up 20200316234553 Create goods
up 20200320001554 Create answers
up 20200321045545 Add price to goods
up 20200322074614 Create uploads
up 20200329025030 Create foods
up 20200331133141 Create foodanswers
up 20200404003441 Create shops
up 20200404122834 Create shopers
down 20200405083649 Create profiles
down 20200409124823 Add user id to goods
down 20200409135429 Add user id to foods
down 20200410125803 Add user id to shops
down 20200410131119 Add user id to uploads
エラー文の中にPG::UndefinedColumn: ERROR: column "confirmation_token" does not existと表記があったので、
現状、devise_create_users.rbでは、confirmation_token部分はコメントアウト状態ですが、
外した方が良いのでしょうか。
class DeviseCreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts t.string :unlock_token # Only if unlock strategy is :email or :both t.datetime :locked_at t.timestamps null: false end add_index :users, :email, unique: true add_index :users, :reset_password_token, unique: true add_index :users, :confirmation_token, unique: true add_index :users, :unlock_token, unique: true
end
end
不足情報ございましたら、ご指摘ください。
よろしくお願いいたします。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/04/22 14:11