質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

Q&A

解決済

1回答

3857閲覧

PG::UndefinedTable: ERROR: relation "users" does not existについて

kinakoo

総合スコア5

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

データベース

データベースとは、データの集合体を指します。また、そのデータの集合体の共用を可能にするシステムの意味を含めます

ログイン

ログインは、ユーザーがコンピューターシステムにアクセスするプロセスの事を呼びます。

0グッド

0クリップ

投稿2021/09/20 07:03

前提・実現したいこと

sorceryでログイン機能を実装しようとしたところ、
タイトルにあるようなエラーが発生しました。
この記事を参考にしてraile db:migrateまで行いました。

発生している問題・エラーメッセージ

$ rake db:migrate == 20210920044052 AddOmniauthToUsers: migrating =============================== -- add_column(:users, :provider, :string) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::UndefinedTable: ERROR: relation "users" does not exist /Library/Ruby/Gems/2.6.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:110:in `exec' /Library/Ruby/Gems/2.6.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:110:in `async_exec' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block (2 levels) in execute' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `block in execute' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block (2 levels) in log' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log' /Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.4.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:45:in `execute' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:611:in `add_column' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:398:in `add_column' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:929:in `block in method_missing' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:897:in `block in say_with_time' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:897:in `say_with_time' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:918:in `method_missing' /Users/adachinana/login/db/migrate/20210920044052_add_omniauth_to_users.rb:3:in `change' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:867:in `exec_migration' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:851:in `block (2 levels) in migrate' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/migration.rb:850:in `block in migrate' /Library/Ruby/Gems/2.6.0/gems/activerecord-6.1.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection' Caused by: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "users" does not exist ・ ・ ・ /Library/Ruby/Gems/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>' Tasks: TOP => db:migrate (See full trace by running task with --trace)

試したこと

$ rake db:migrate:status database: login_development Status Migration ID Migration Name -------------------------------------------------- down 20210920044052 Add omniauth to users down 20210920051530 Sorcery core

といった状況であったために、
rake db:migrate VERSION=20210920051530
を試してみましたが、解決できませんでした。

補足情報(FW/ツールのバージョンなど)

ruby 2.6.3
Rails 6.1.4.1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

マイグレーションする順番が問題かと思います。
エラーから推測して、参照しようとしているusersテーブルがないと思われます。

なので、

down 20210920051530 Sorcery core

を先に作成、実行すべきかと思われます。

rake db:migrate VERSION=20210920051530

ですが、upが足らないかも、、?

試してみてください。

投稿2021/09/20 09:03

tani__san929

総合スコア61

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kinakoo

2021/09/22 01:48

ありがとうございます!解決しました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問