fix(deploy): run migrations before server boot to prevent stale schema errors
Sidekiq was starting before migrations ran, causing RuntimeError on the group_type enum. Moved db:chatwoot_prepare from post_start into the rails entrypoint and made sidekiq depend on the rails healthcheck. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ec587bb5ee
commit
3aba6affd4
@ -46,7 +46,7 @@ services:
|
||||
- command:
|
||||
- sh
|
||||
- '-c'
|
||||
- 'bundle exec rails db:chatwoot_prepare && bundle exec rails branding:update && if [ -n "$${BRAND_ASSETS_URL}" ]; then deployment/extract_brand_assets.sh "$${BRAND_ASSETS_URL}"; fi'
|
||||
- 'bundle exec rails branding:update && if [ -n "$${BRAND_ASSETS_URL}" ]; then deployment/extract_brand_assets.sh "$${BRAND_ASSETS_URL}"; fi'
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
@ -61,8 +61,12 @@ services:
|
||||
volumes:
|
||||
- 'storage:/app/storage'
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
rails:
|
||||
condition: service_healthy
|
||||
postgres:
|
||||
condition: service_started
|
||||
redis:
|
||||
condition: service_started
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- RAILS_ENV=production
|
||||
|
||||
@ -30,5 +30,11 @@ do
|
||||
sleep 2;
|
||||
done
|
||||
|
||||
# Run pending migrations before starting the server so that workers
|
||||
# (sidekiq) that depend on the rails healthcheck never see a stale schema.
|
||||
echo "Running db:chatwoot_prepare..."
|
||||
bundle exec rake db:chatwoot_prepare
|
||||
echo "Database preparation complete."
|
||||
|
||||
# Execute the main process of the container
|
||||
exec "$@"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user