fix(test): Postgres tests fail with relation "oauth_inits" already exists (missing from teardown list) #259
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol#259
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
PR / Test (postgres)has been failing on every PR since #215 was merged (08f177d, 2026-06-23). The SQLite leg passes; every other job passes; onlyTest (postgres)fails, deterministically, ~30–70s into theRun viteststep.Root cause
apps/api/tests/db/_engines.tskeeps a hardcodedKYSELY_TABLESlist of every table the migrator creates. Before each test suite's setup, that list is dropped (DROP TABLE IF EXISTS …) so the migrator can re-run cleanly against the shared Postgres database. 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) introduced anoauth_initstable, but #215 did not add"oauth_inits"toKYSELY_TABLES. Consequence: on suite #2+ against the shared Postgres DB, the teardown drops everything exceptoauth_inits(includingkysely_migration*), then the migrator re-runs from scratch and migration 012 trips over the leftoveroauth_initstable:Reproduced locally against
postgres:16in 73s.Fix
One-line addition to
KYSELY_TABLESinapps/api/tests/db/_engines.tsso theoauth_initstable is included in the teardown list.Defence-in-depth follow-up (separate ticket if desired)
The failure mode is generic: any new migration that adds a table will trip this trap if the author forgets the teardown list. Options:
information_schema.tablesand drop everything in the public schema rather than maintaining a hardcoded list.KYSELY_TABLESis a superset ofcreateTable(…)calls underapps/api/db/migrations/.Deferring to a follow-up — this ticket is just the surgical fix to unblock CI.
Note on the unrelated
~10m02sinfra hangOne recent run (#561) shows the runner-provisioning timeout pattern — eight jobs all failing at exactly 10m02s during the
Set up jobstep. That's a separate Forgejo Actions infrastructure hang, not in scope here. It has occurred once in the last 20 failingTest (postgres)tasks; the dominant pattern is the migration teardown bug fixed in this PR.