fix(test): include oauth_inits in postgres teardown table list #261

Merged
james merged 1 commit from fix-postgres-tests-oauth-inits into main 2026-06-23 17:29:55 +00:00
Owner

Summary

  • Adds "oauth_inits" to the KYSELY_TABLES drop list in apps/api/tests/db/_engines.ts.
  • Fixes the Test (postgres) job failing with relation "oauth_inits" already exists on every PR since #215 merged.

Why

The per-suite Postgres setup drops every table in KYSELY_TABLES (including the kysely_migration* bookkeeping tables) before re-running the migrator from scratch — that's how the shared CI Postgres database stays clean between test files. SQLite uses :memory: so each suite gets a brand-new DB and the list doesn't matter there.

Migration 012_oauth_inits (added in #215) created an oauth_inits table but did not extend KYSELY_TABLES. So on the second-and-later suite, kysely_migration* is wiped, the migrator thinks no migrations have run, replays 001→013, and migration 012 trips over the leftover oauth_inits table:

error: relation "oauth_inits" already exists
  at Object.up db/migrations/012_oauth_inits.ts:53:5

One-line fix.

Test plan

  • Reproduced locally against postgres:16 — full vitest run failed with the same error and the same migration-012 stack.
  • Applied the fix; re-ran TEST_POSTGRES_URL=postgres://… pnpm -F @carol/api test748/748 pass, 50/50 suites pass.
  • CI on this PR confirms Test (postgres) is green.

Note on the ~10m02s runner-provisioning hangs

In the last 20 failing Test (postgres) tasks, exactly one (run #561) shows the runner-provisioning timeout pattern — eight jobs all dying at 10m02s during Set up job. That's a separate Forgejo Actions infrastructure hang, not in scope here.

Closes #259.

## Summary - Adds `"oauth_inits"` to the `KYSELY_TABLES` drop list in `apps/api/tests/db/_engines.ts`. - Fixes the `Test (postgres)` job failing with `relation "oauth_inits" already exists` on every PR since #215 merged. ## Why The per-suite Postgres setup drops every table in `KYSELY_TABLES` (including the `kysely_migration*` bookkeeping tables) before re-running the migrator from scratch — that's how the shared CI Postgres database stays clean between test files. SQLite uses `:memory:` so each suite gets a brand-new DB and the list doesn't matter there. Migration `012_oauth_inits` (added in #215) created an `oauth_inits` table but did not extend `KYSELY_TABLES`. So on the second-and-later suite, `kysely_migration*` is wiped, the migrator thinks no migrations have run, replays 001→013, and migration 012 trips over the leftover `oauth_inits` table: ``` error: relation "oauth_inits" already exists at Object.up db/migrations/012_oauth_inits.ts:53:5 ``` One-line fix. ## Test plan - [x] Reproduced locally against `postgres:16` — full vitest run failed with the same error and the same migration-012 stack. - [x] Applied the fix; re-ran `TEST_POSTGRES_URL=postgres://… pnpm -F @carol/api test` — **748/748 pass, 50/50 suites pass**. - [x] CI on this PR confirms `Test (postgres)` is green. ## Note on the `~10m02s` runner-provisioning hangs In the last 20 failing `Test (postgres)` tasks, exactly one (run #561) shows the runner-provisioning timeout pattern — eight jobs all dying at 10m02s during `Set up job`. That's a separate Forgejo Actions infrastructure hang, not in scope here. Closes #259.
fix(test): include oauth_inits in postgres teardown table list
All checks were successful
Commits / Conventional Commits (pull_request) Successful in 31s
PR / Static analysis (pull_request) Successful in 1m31s
PR / OpenAPI (pull_request) Successful in 2m4s
PR / Typecheck (pull_request) Successful in 2m51s
PR / Lint (pull_request) Successful in 2m58s
PR / Package age policy (soft) (pull_request) Successful in 34s
Secrets / gitleaks (pull_request) Successful in 53s
PR / Client (web export smoke) (pull_request) Successful in 3m29s
PR / Test (sqlite) (pull_request) Successful in 2m24s
PR / Build (pull_request) Successful in 3m50s
PR / Test (postgres) (pull_request) Successful in 2m38s
PR / OSV-Scanner (pull_request) Successful in 2m17s
PR / pnpm audit (pull_request) Successful in 2m56s
PR / Trivy (image) (pull_request) Successful in 2m38s
PR / Coverage (soft) (pull_request) Successful in 2m1s
4151e9cafd
Migration 012_oauth_inits introduced an `oauth_inits` table but the
hardcoded `KYSELY_TABLES` drop list in `apps/api/tests/db/_engines.ts`
was not updated. Against the shared CI Postgres database the test
setup drops every other table (including `kysely_migration*`), the
migrator then re-runs from scratch, and migration 012 fails with
`relation "oauth_inits" already exists`. SQLite is unaffected because
each suite gets a fresh `:memory:` DB. Adds the missing entry so
teardown wipes `oauth_inits` too.

Closes #259.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

📊 Test coverage

Patch coverage: no testable lines changed.

Overall (app/, lib/, db/, excluding UI per ADR-0019):

Metric Value Soft target
Lines 82.9% ≥ 50%
Branches 75.6% ≥ 75%
Functions 91.8% informational

Soft thresholds per ADR-0019. Coverage is informational and does not block merge.

<!-- coverage-comment --> ## 📊 Test coverage **Patch coverage:** no testable lines changed. **Overall** (`app/`, `lib/`, `db/`, excluding UI per ADR-0019): | Metric | Value | Soft target | |---|---|---| | Lines | 82.9% ✅ | ≥ 50% | | Branches | 75.6% ✅ | ≥ 75% | | Functions | 91.8% | informational | Soft thresholds per [ADR-0019](docs/adr/0019-coverage-soft-targets.md). Coverage is informational and does not block merge.
james merged commit 1d3207a764 into main 2026-06-23 17:29:55 +00:00
james deleted branch fix-postgres-tests-oauth-inits 2026-06-23 17:29:55 +00:00
Sign in to join this conversation.
No description provided.