From d7485c09dd52a966954087f46e5d843e116f980a Mon Sep 17 00:00:00 2001 From: Omar Selo Date: Fri, 3 Nov 2023 12:44:01 +0300 Subject: [PATCH] Fix ORM model and add alembic check (#60) * Correct Artefact ORM model to match migrations * Add CI check to catch if alembic detects migrations * Try a fix to alembic action * Try a fix to alembic action * Try a fix to alembic action * Bring back rest of backend test CI * Bug fix --- .github/workflows/test_backend.yml | 7 +++++++ backend/test_observer/data_access/models.py | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index a2718155..e3f5c7cc 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -37,3 +37,10 @@ jobs: - run: poetry run pytest env: TEST_DB_URL: postgresql+pg8000://postgres:password@localhost:5432/postgres + - run: poetry run alembic upgrade head + env: + DB_URL: postgresql+pg8000://postgres:password@localhost:5432/postgres + - name: Check if alembic migrations are up to date + run: poetry run alembic check + env: + DB_URL: postgresql+pg8000://postgres:password@localhost:5432/postgres diff --git a/backend/test_observer/data_access/models.py b/backend/test_observer/data_access/models.py index 9cd9101a..9cc2edf5 100644 --- a/backend/test_observer/data_access/models.py +++ b/backend/test_observer/data_access/models.py @@ -109,9 +109,8 @@ class Artefact(Base): status: Mapped[ArtefactStatus | None] __table_args__ = ( - UniqueConstraint( - "name", "version", "track", "series", "repo", name="unique_artefact" - ), + UniqueConstraint("name", "version", "track", name="unique_snap"), + UniqueConstraint("name", "version", "series", "repo", name="unique_deb"), ) def __repr__(self) -> str: