ProjectTech4DevAI / ProjectTech4DevAI/kaapi-backend

Fail CI if Alembic autogenerate detects schema drift

Open
#287 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
18
Forks
10
Avg merge
2d 20h
Merged PRs (30d)
14

Description

Description
At present, we don’t have an automated way to ensure that our SQLModel data models and the database schema are in sync. The only way to check is manually, typically by running the alembic revision command. However, this step can easily be overlooked by someone pushing code, which can lead to inconsistencies accumulating over time. To automate this verification, we should add a CI step that runs:

alembic revision --autogenerate -m "ci check"

and then verifies that the generated migration file is empty (i.e., it contains no upgrade()/downgrade() operations).

If alembic generates non-empty changes, the CI job should fail, signalling a mismatch between the current database schema and our models.

Acceptance Criteria

  • Add a step in GitHub Actions workflow to run alembic revision --autogenerate against the test database.

  • Fail the job if the generated migration contains actual schema changes.

  • Clean up the generated revision file after the check.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the GitHub Actions workflow and the existing test-database setup, then review the Alembic configuration used by the project. Run the specified autogenerate command against that database and determine how to detect non-empty upgrade()/downgrade() operations. Done means the workflow fails on schema drift and removes the generated revision afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, python
Domain
ci-cd, database
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.