LoginSignup
0
0

More than 3 years have passed since last update.

ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "users" does not exist

Posted at

アプリを初めてherokuにデプロイすると、下記のエラーが出た。

remote:        ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "users" does not exist
remote:        LINE 8:                WHERE a.attrelid = '"users"'::regclass
remote:                                                  ^
remote:        :               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
remote:                             pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
remote:                             c.collname, col_description(a.attrelid, a.attnum) AS comment
remote:                        FROM pg_attribute a
remote:                        LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
remote:                        LEFT JOIN pg_type t ON a.atttypid = t.oid
remote:                        LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
remote:                       WHERE a.attrelid = '"users"'::regclass
remote:                         AND a.attnum > 0 AND NOT a.attisdropped

下記の記事を見ていると、
初回herokuデプロイ時、deviseで紐付けているモデルでscopeを定義していると発生する様子。

参考
https://github.com/rails/rails/issues/36755

なのでscopeをコメントアウトし、再度デプロイ。

$ git push heroku master

するとデプロイが出来た。

デプロイ後、コメントアウトしていたscopeをコメントインし、再度デプロイするとscopeを反映させることが出来た。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0