ProjectTech4DevAI / ProjectTech4DevAI/kaapi-backend

Fail CI if Alembic autogenerate detects schema drift

オープン
#287 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement
主要言語
Python
スター
18
フォーク
10
平均マージ
2日 20時間
マージ済み PR(30日)
14

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

GitHub Actions の workflow と既存のテストデータベースのセットアップを確認し、その後、プロジェクトで使用されている Alembic の設定を調べてください。そのデータベースに対して指定された autogenerate コマンドを実行し、空でない upgrade()/downgrade() 操作を検出する方法を決定してください。workflow がスキーマドリフトで失敗し、その後に生成された revision を削除すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
github-actions, python
領域
ci-cd, database
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。