Skip to content

Commit 55e8d83

Browse files
committed
Fix Render deployment: move db:migrate to preDeployCommand
- Remove db:migrate from build script (database not accessible during build) - Add preDeployCommand for migrations (runs at deploy time) - Remove explicit database names from cache/queue/cable (use URL only) - Fixes: 'could not translate host name' error on Render
1 parent 9000234 commit 55e8d83

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

bin/render-build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ set -o errexit
55
bundle install
66
bin/rails assets:precompile
77
bin/rails assets:clean
8-
bin/rails db:migrate
8+
9+
# NOTE: db:migrate moved to startCommand - database not available during build

config/database.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,12 @@ production:
9292
cache:
9393
<<: *primary_production
9494
url: <%= ENV["CACHE_DATABASE_URL"] || ENV["DATABASE_URL"] %>
95-
database: task_tracker_production_cache
9695
migrations_paths: db/cache_migrate
9796
queue:
9897
<<: *primary_production
9998
url: <%= ENV["QUEUE_DATABASE_URL"] || ENV["DATABASE_URL"] %>
100-
database: task_tracker_production_queue
10199
migrations_paths: db/queue_migrate
102100
cable:
103101
<<: *primary_production
104102
url: <%= ENV["CABLE_DATABASE_URL"] || ENV["DATABASE_URL"] %>
105-
database: task_tracker_production_cable
106103
migrations_paths: db/cable_migrate

render.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
runtime: ruby
1111
plan: free
1212
buildCommand: "./bin/render-build.sh"
13+
preDeployCommand: "bin/rails db:migrate"
1314
startCommand: "bin/rails server"
1415
envVars:
1516
- key: DATABASE_URL

0 commit comments

Comments
 (0)