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:
|
- command:
|
||||||
- sh
|
- sh
|
||||||
- '-c'
|
- '-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:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
- CMD-SHELL
|
- CMD-SHELL
|
||||||
@ -61,8 +61,12 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- 'storage:/app/storage'
|
- 'storage:/app/storage'
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
rails:
|
||||||
- redis
|
condition: service_healthy
|
||||||
|
postgres:
|
||||||
|
condition: service_started
|
||||||
|
redis:
|
||||||
|
condition: service_started
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- RAILS_ENV=production
|
- RAILS_ENV=production
|
||||||
|
|||||||
@ -30,5 +30,11 @@ do
|
|||||||
sleep 2;
|
sleep 2;
|
||||||
done
|
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
|
# Execute the main process of the container
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user