ci: EF migration integrity checks for SQLite + MySql (#13) #30

Merged
timothy merged 1 commits from foundations/13-migration-checks into main 2026-06-27 11:05:00 +02:00
Owner

Refs #13. New migrations job in docker-build.yml that protects every future schema change (and the prod cutover, server-management#481). Runs on every push/PR; for each provider:

  1. Model-drift — dotnet ef migrations has-pending-model-changes fails if an entity changed without a matching migration (so a forgotten migration can't merge).
  2. Apply-to-fresh — dotnet ef database update against a fresh empty DB applies all migrations in order, catching broken/un-orderable ones.

Providers

  • SQLite (prod provider): throwaway file (ETV_CONFIG_FOLDER=$(mktemp -d)), no service.
  • MySql: Startup uses ServerVersion.AutoDetect (connects at config time), so the job runs a services: mysql:8.4 container. Confirmed the runner (act_runner v0.6.1, Docker execution, network downloadswarm) supports services → reachable as mysql:3306. Connection via MySql__ConnectionString.

Validated locally against real DBs (before pushing)

  • SQLite: drift clean; 787 migrations → 139 tables.
  • MySql 8.4: drift clean; 305 migrations → 137 tables.
    (EF CLI pattern from scripts/add-migration.sh: --startup-project ErsatzTV --project …{Sqlite|MySql} -- --provider {Sqlite|MySql}.)

Notes

  • Independent gate for now (not a needs: of the image build) so the new MySql-service dependency can't block image builds until it's proven on the runner. Promote to a required check / build dependency once green.
  • Docs: ci-cd.md → Migration integrity (dual-provider discipline, the non-transactional caveat) + a CLAUDE.md convention.

The migrations job's real-CI run here is the verification that the MySql services: container works on the runner.

Refs #13. New **`migrations`** job in `docker-build.yml` that protects every future schema change (and the prod cutover, server-management#481). Runs on every push/PR; for **each** provider: 1. **Model-drift** — `dotnet ef migrations has-pending-model-changes` fails if an entity changed without a matching migration (so a forgotten migration can't merge). 2. **Apply-to-fresh** — `dotnet ef database update` against a fresh empty DB applies *all* migrations in order, catching broken/un-orderable ones. ## Providers - **SQLite** (prod provider): throwaway file (`ETV_CONFIG_FOLDER=$(mktemp -d)`), no service. - **MySql**: `Startup` uses `ServerVersion.AutoDetect` (connects at config time), so the job runs a **`services: mysql:8.4`** container. Confirmed the runner (`act_runner v0.6.1`, Docker execution, network `downloadswarm`) supports services → reachable as `mysql:3306`. Connection via `MySql__ConnectionString`. ## Validated locally against real DBs (before pushing) - SQLite: drift clean; **787 migrations → 139 tables**. - MySql 8.4: drift clean; **305 migrations → 137 tables**. (EF CLI pattern from `scripts/add-migration.sh`: `--startup-project ErsatzTV --project …{Sqlite|MySql} -- --provider {Sqlite|MySql}`.) ## Notes - **Independent gate** for now (not a `needs:` of the image `build`) so the new MySql-service dependency can't block image builds until it's proven on the runner. Promote to a required check / build dependency once green. - Docs: `ci-cd.md` → **Migration integrity** (dual-provider discipline, the non-transactional caveat) + a `CLAUDE.md` convention. The `migrations` job's real-CI run here is the verification that the MySql `services:` container works on the runner.
timothy added 1 commit 2026-06-27 10:58:59 +02:00
ci: EF migration integrity checks for SQLite + MySql (#13)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 3m56s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m59s
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 4m12s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 5m26s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 3m33s
307da32f34
New `migrations` job in docker-build.yml runs on every push/PR and, per provider:
- `dotnet ef migrations has-pending-model-changes` — fails on model drift (an entity
  changed without a matching migration).
- `dotnet ef database update` against a fresh empty DB — applies all migrations,
  catching broken/un-orderable ones.

SQLite (the prod provider) uses a throwaway file; MySql uses ServerVersion.AutoDetect
(connects at config time), so the job runs a `services: mysql:8.4` container (the
act_runner uses Docker execution on network downloadswarm, so the service is reachable
as `mysql:3306`). Independent gate for now (not a `needs:` of the image build) so the
MySql-service dependency can't block image builds until proven stable.

Validated both providers locally against real DBs: SQLite 787 migrations -> 139 tables;
MySql 8.4 305 migrations -> 137 tables; both model-drift checks clean.

Docs: ci-cd.md "Migration integrity" (dual-provider discipline, EF CLI pattern, the
non-transactional caveat) + CLAUDE.md convention.

Refs #13

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
timothy merged commit 307da32f34 into main 2026-06-27 11:05:00 +02:00
timothy deleted branch foundations/13-migration-checks 2026-06-27 11:05:00 +02:00
Sign in to join this conversation.