-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-48385: Add Alembic integration #88
Merged
Merged
Conversation
This file contains 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
This Alembic integration is described in https://safir.lsst.io/user-guide/database/schema.html#set-up-alembic - Includes Alembic configuration files, and adds those Alembic files to the Dockerfile to run online migrations. - Modifies the init CLI command to ensure the database is stamped with the current schema - Includes addition CLI commands for applying the alembic migration and for verifying that hte DB schema is current - Updates the start up of the FastAPI service and the Arq workers to check that the database is current
This initial Alembic migration is created via: docker-compose -f docker-compose.yaml up tox run -e alembic -- revision --autogenerate -m "Initial schema." While doing this we discovered some tweaks to ruff formatting: - Adjusted template - Added ruff configurations to pyproject.toml
Since the dockerfile "knows" where the alembic configuration is, we'll add the env var configuration there rather than putting it as a command line default.
jonathansick
added a commit
to lsst-sqre/phalanx
that referenced
this pull request
Jan 13, 2025
This job is based on the same one developed for Gafaelfaawr and will be part of a semi-manual process for running Alembic migrations when needed (e.g. following https://phalanx.lsst.io/applications/gafaelfawr/manage-schema.html#updating-the-database-schema). See also the Times Square PR: lsst-sqre/times-square#88
It turns out stamp_database needs to run from a sync context because it'll run its own asyncio even loop to call `run_async_migrations`. Therefore we're following Gafaelfawr's pattern of making init sync but then running an extracted database initialization function via asyncio.run.
This test from https://safir.lsst.io/user-guide/database/schema.html#testing-database-migrations ensures that the SQLAlchemy models are consistent with the current revision of the Alembic migrations.
- Link to deployments - Link to documentation sites
sebastian-aranda
pushed a commit
to lsst-sqre/phalanx
that referenced
this pull request
Jan 14, 2025
This job is based on the same one developed for Gafaelfaawr and will be part of a semi-manual process for running Alembic migrations when needed (e.g. following https://phalanx.lsst.io/applications/gafaelfawr/manage-schema.html#updating-the-database-schema). See also the Times Square PR: lsst-sqre/times-square#88
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.
This adds Alembic integration for managing Times Square's SQL database schema, using the methodology developed in Safir. This includes the initial migration, tooling to create migrations, and modifications to the FastAPI and Arq workers to check that the database is up to date. This will be released as version 0.14.0.