Run migrations as a separate step, not on app startup#61
Merged
Conversation
Switch from migrating on container startup to applying migrations as a dedicated step before rollout, so the long-lived app pods can run with a read-only database user. In production this is a Helm pre-install/pre-upgrade hook job that runs `alembic upgrade head` using the app image; the chart lives in eclipse-csi/helm-charts. - Dockerfile: CMD is plain uvicorn again (no startup migration); the alembic CLI remains in the image so the hook job can override the command. Remove start.sh, which is no longer needed. - alembic/env.py: read the DB URL straight from PIA_DATABASE_URL instead of constructing the full app Settings, so migrations only depend on the database connection (not the Dependency Track API key) and can run under a dedicated, minimally-scoped DB user. Mirrors how cli.py reads the URL. - docker-compose.yml: keep the dev-only convenience of chaining migration with the app start, inline, documented as dev-only. - CI: run "alembic upgrade head" as its own step (mirroring the hook) before the uvicorn smoke test, exercising both the migration scripts and app boot. - README: document the separate-step / Helm hook migration model. Signed-off-by: Lukas Puehringer <lukas.puehringer@eclipse-foundation.org> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mbarbero
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch from migrating on container startup to applying migrations as a dedicated step before rollout, so the long-lived app pods can run with a read-only database user. In production this is a Helm pre-install/pre-upgrade hook job that runs
alembic upgrade headusing the app image; the chart lives in eclipse-csi/helm-charts.