Scope
A single commit on 2026-04-27. Late but significant — added the schema_migrations tracking table that should have existed from the start.
Commit
81c2568 — 2026-04-27 — feat(migrations): add schema_migrations tracking and resolve 007 issues
Co-author: Claude Opus 4.7 (1M context).
What landed:
migrations/000_schema_migrations.sql— bootstraps a tracking table:versionPRIMARY KEY (TEXT).namenullable TEXT for legacy compatibility (some migrations insert without supplying a name).applied_atTIMESTAMPTZ DEFAULT NOW().
- Renamed later-committed
007_add_archive_tables.sql→009_add_archive_tables.sqlto resolve a numbering collision with007_pgvector_company_embeddings.sql(kept as 007). - New runner:
scripts/migrate.ts. Idempotent. UsesBun.sqlfor bookkeeping andpsql -ffor migration bodies. Supports--mark-applied <version>to backfill rows for migrations applied out-of-band before tracking existed. - Fixed migration 007 (the surviving 007, pgvector): removed an illegal
BEGIN/COMMITwrapper aroundCREATE INDEX CONCURRENTLYstatements. Dropped a strayidx_bv_sni_primarythat referenced a column that does not exist onbolagsverket_companies. - Wired
bun run migrateinpackage.json.
Verification cited in body: “all 10 migrations apply cleanly against the live DB and a re-run is a no-op (applied=0 skipped=10).”
Significance
- Before this commit the project had 10 migrations and no record of which ones had been applied. Anyone setting up a fresh DB had to read each
*.sqland check by hand. - The numbering collision is a permanent record: if you
git logfor007_add_archive_tables.sqlyou will find it under both filenames. This commit is where the rename happened. - The
--mark-appliedmode is the migration path for existing prod databases. Run it once per applied version to backfill the tracking table.
See also
Schema Migrations, Database Schema, History Archive Era, History Overview.