0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Render】不具合対応について

Last updated at Posted at 2025-06-11

記事概要

Renderで不具合が発生した際の対応方法について、まとめる

エラーログの確認

  1. ログを確認するアプリを、選択する
  2. メニューから「Monitor」の「Logs」を選択する
  3. ログが表示される

データベースをリセット

ケース

下記条件に当てはまる場合に実施する

  • カラムの追加などのテーブルの変更を行った
  • ローカルでは、変更内容が正しく反映する
  • Renderでデプロイを行った際に、エラーは出ないがテーブルに上記の変更が反映されない

注意点

登録済みのデータが、すべて削除される

手順(Rails)

  1. bin/render-build.shを変更する
    1. bundle exec rake db:migrateを、コメントアウトする
    2. DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:migrate:resetを、追加する
      • DISABLE_DATABASE_ENVIRONMENT_CHECK=1
        →本番環境のデータベースを削除するために必要な設定
        →本番用のデータベースには重要なデータが含まれるため、通常は削除できない
      • bundle exec rake db:migrate:reset
        以下を実施したことと同義になる
        • rake db:drop(データベースの削除)
        • rake db:create(データベースの作成)
        • rake db:migrate(マイグレーションファイルの実行)
      bin/render-build.sh
      #!/usr/bin/env bash
      # exit on error
      set -o errexit
      
      bundle install
      bundle exec rake assets:precompile
      bundle exec rake assets:clean
      # bundle exec rake db:migrate
      DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:migrate:reset
      
  2. TablePlusを終了する ※データベースをTablePlusで開いている場合、削除できない
  3. GitHubにプッシュし、更新する
  4. GitHubにコードをプッシュすると、Renderのデプロイが実行される
  5. Railsの設定をもとに戻す
    bin/render-build.sh
    #!/usr/bin/env bash
    # exit on error
    set -o errexit
    
    bundle install
    bundle exec rake assets:precompile
    bundle exec rake assets:clean
    bundle exec rake db:migrate
    
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?