-
Notifications
You must be signed in to change notification settings - Fork 517
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
Adding linting to migrations #4874
Conversation
Eugene 🔒 lint report of
|
Eugene 🔒 lint report of
|
@@ -405,32 +407,41 @@ def upgrade_database(tag, sql, revision, revision_type): | |||
from .database.manage import init_database | |||
|
|||
alembic_cfg = AlembicConfig(config.ALEMBIC_INI_PATH) | |||
path = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the playwright tests are failing since the path
is still None
and line set_main_option
in line 418 requires a string.
if revision_type: | ||
if revision_type == "core": | ||
path = config.ALEMBIC_CORE_REVISION_PATH | ||
alembic_cfg.set_main_option("script_location", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alembic_cfg.set_main_option("script_location", path) | |
alembic_cfg.set_main_option("script_location", path) |
This PR is stale, because it has been open for 45 days with no activity. Remove the stale label or comment, or this will be closed in 10 days. |
This PR was closed, because it has been stalled for 10 days with no activity. |
This PR adds a new type of linting for our alembic migration files. It dumps all migrations to .sql files and then runs a subset of linting rules that looks for problematic locks and other issues. Currently, it only attempts to look at the last added revision, as we generally only have one migration per pr; I think this is probably reasonable. If we find value we can extend this a bit.
Documentation reference: https://kaveland.no/eugene/introduction.html
Additionally, I have added several improvements to the actual migrations themselves based on the advice here:
https://squawkhq.com/docs/web-frameworks/#alembic-and-sqlalchemy. This should help prevent migrations from locking up the database if we accidentally introduce a change that requires exclusivity.