fix: rebuild migration history as baseline so migrate works on prod

Squash the 13 historical migrations into one generated baseline whose
journal entry reuses the original 0000 timestamp: the migrator skips it
on every existing database (prod journal stuck at 0006) and applies it
only on fresh ones. Parity with the old chain verified via pg_dump diff
plus fresh/existing/prod-simulated drizzle-kit migrate runs. Historical
files move to drizzle-history/pre-squash-2026-08/ for integration tests
that exercise legacy migration behavior.

Also repair db tests that already failed before this change:
- raw SQL targeted users, but the table has always been "user"
- membership recheck mocked legacy getAsset.albums instead of searchPhotos
- audit rollback assertion walks drizzle's wrapped error cause chain
- keyset index probe pinned to NULLS LAST ordering, removing a planner
  cost tie-break that flipped with index creation order
This commit is contained in:
Leon Tonhäuser committed 2026-08-25 11:56:52 +02:00
1 parent 2949149170
commit 0b65fbba16
40 files changed
+2389 -128

No files matched your search

+11
View File
@@ -81,6 +81,17 @@ the `ops` compose profile and do not start with `docker compose up`.
```bash
docker compose --profile ops run --rm migrate
```
Migrations are safe to run on every environment, including production. The
history was squashed into a single baseline (`drizzle/0000_baseline.sql`) in
August 2026: the baseline carries the timestamp of the original first
migration, so `drizzle-kit migrate` skips it on any database that already has
tables (its recorded journal entry is newer) and applies it only on fresh
databases. New migrations generated with `pnpm exec drizzle-kit generate` are
picked up automatically on all environments — no manual psql steps required
anymore. Historical (pre-squash) migration files live in
`drizzle-history/pre-squash-2026-08/` and are referenced by integration tests
only; do not point `drizzle.config.ts` at that folder.
- **Seed the first admin** (override the command to pass credentials):
```bash
docker compose --profile ops run --rm seed \