You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The validate job's Run migrations step (pnpm run migration:run against a fresh Postgres, added by #1070) has never passed and blocks validate for every PR, independently of the code under test.
Root cause
The migrations in src/migrations/ are incremental patches authored on top of a schema that TypeORM creates via synchronize in dev (getDatabaseConfig() sets synchronize: process.env.NODE_ENV !== 'production'). There is no baseline migration that creates the core tables (users, courses, …).
On an empty CI database the run therefore fails immediately:
QueryFailedError: relation "users" does not exist
at CreateMessageTable1630000000000.up
query: ALTER TABLE "messages" ADD CONSTRAINT "FK_..." FOREIGN KEY ("senderId") REFERENCES "users"("id") ...
The very first migration assumes users already exists, so migration:run from scratch cannot succeed with the current migration set.
Timeline
Last green validate on main: commit 79b9942 (2026-07-29 06:52 UTC) — before the migrations step existed.
Two prerequisites that were also broken have been resolved on the way to reproducing this cleanly:
Migrations glob in src/config/datasource.ts narrowed to src/migrations/[0-9]*.{ts,js} so schema-migration.service.ts and entities/migration.entity.ts are no longer loaded as migrations (this matches the migration:generate:check script's own find ... -name '[0-9]*.ts' convention). Renamed AddTimezoneLocalePreferences.ts → 1710000000000-AddTimezoneLocalePreferences.ts.
Added 1600000000000-enable-uuid-ossp.ts (CREATE EXTENSION IF NOT EXISTS "uuid-ossp") so migrations that default ids to uuid_generate_v4() work on a fresh DB.
With those in place, migration:run now progresses to the missing-baseline failure above.
Options to resolve (decision needed)
Author a baseline schema migration (lowest timestamp) generated from the current entities so migration:run builds the full schema from scratch, ensuring the existing incremental migrations still apply cleanly on top. Needs a live DB and careful verification against the drift check.
Bootstrap the schema before the dry-run in CI (e.g. create it via synchronize from entities, then run migrations) — changes the intent of the from-scratch dry-run.
Summary
The
validatejob's Run migrations step (pnpm run migration:runagainst a fresh Postgres, added by #1070) has never passed and blocksvalidatefor every PR, independently of the code under test.Root cause
The migrations in
src/migrations/are incremental patches authored on top of a schema that TypeORM creates viasynchronizein dev (getDatabaseConfig()setssynchronize: process.env.NODE_ENV !== 'production'). There is no baseline migration that creates the core tables (users,courses, …).On an empty CI database the run therefore fails immediately:
The very first migration assumes
usersalready exists, somigration:runfrom scratch cannot succeed with the current migration set.Timeline
validateonmain: commit79b9942(2026-07-29 06:52 UTC) — before the migrations step existed.validaterun since has failed at/around the migrations step.What's already been fixed (see PR #1192)
Two prerequisites that were also broken have been resolved on the way to reproducing this cleanly:
src/config/datasource.tsnarrowed tosrc/migrations/[0-9]*.{ts,js}soschema-migration.service.tsandentities/migration.entity.tsare no longer loaded as migrations (this matches themigration:generate:checkscript's ownfind ... -name '[0-9]*.ts'convention). RenamedAddTimezoneLocalePreferences.ts→1710000000000-AddTimezoneLocalePreferences.ts.1600000000000-enable-uuid-ossp.ts(CREATE EXTENSION IF NOT EXISTS "uuid-ossp") so migrations that default ids touuid_generate_v4()work on a fresh DB.With those in place,
migration:runnow progresses to the missing-baseline failure above.Options to resolve (decision needed)
migration:runbuilds the full schema from scratch, ensuring the existing incremental migrations still apply cleanly on top. Needs a live DB and careful verification against the drift check.synchronizefrom entities, then run migrations) — changes the intent of the from-scratch dry-run.migration:run/migration:revert/drift-check steps introduced in Add automated database migration dry-run step to CI pipeline #1070 until a baseline exists.Acceptance criteria
validate(lint:ci→typecheck→build→migration:run→ drift check →migration:revert) passes on a fresh Postgres.