Skip to content
Snippets Groups Projects
Verified Commit 6f9be959 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add unit test that prevents branching db migrations

parent e97c4f49
No related branches found
No related tags found
1 merge request!178Add unit test that prevents branching db migrations
Pipeline #85944 passed
import pytest
from alembic.migration import MigrationContext
from sqlalchemy import create_engine
@pytest.mark.noautofixt()
def test_migrations_no_branches(db_uri):
engine = create_engine(db_uri)
conn = engine.connect()
context = MigrationContext.configure(conn)
assert len(context.get_current_heads()) == 1, (
"\n\n!!!\n\nDetected a branching of db migrations. This is caused by multiple `down_revision`s referring to the"
" same migration.\n\nPlease resolve this by updating either one of these migrations: "
f"{context.get_current_heads()}.\n\n!!!\n\n"
)
...@@ -13,7 +13,7 @@ deps = ...@@ -13,7 +13,7 @@ deps =
-r requirements.txt -r requirements.txt
commands = commands =
ruff --respect-gitignore --preview . ruff check --respect-gitignore --preview .
ruff format --respect-gitignore --preview --check . ruff format --respect-gitignore --preview --check .
mypy . mypy .
coverage erase coverage erase
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment