7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rails 本番環境 ActiveRecord::StatementInvalid (Mysql2::Error: Table 'テーブル名' doesn't exist):

Posted at

##この記事について
本番環境で出たエラーの対処方法を備忘録として投稿

[環境]
・Ruby 2.6.6, Rails 6.0.3.2
・Docker,Docker-compose(開発環境)

##問題のエラー

qiita.rb
ActiveRecord::StatementInvalid (Mysql2::Error: Table 'テーブル名' doesn't exist):

##エラーが出た原因
開発環境で新たにテーブルを作成したが、本番環境にはまだテーブルが存在しておらずdb:migrateがする必要があるから

##エラーを解決するために

qiita.rb
$ bundle exec rails db:migrate RAILS_ENV=production

== 20200825055854 CreateNews: migrating =======================================
-- create_table(:テーブル名)
   -> 0.0916s
== 20200825055854 Createテーブル名: migrated (0.0918s) ==============================

これでエラーが出なくなった!!!!

7
6
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
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?