Public: anyone can read this; the crew can change it.
Migrations are files with names: two pulls add two files and never collide #943
Closes #783. For authors: a new migration is a new file, src/core/migrations/ .sql. Never append to schema.ts, whose positional list is now closed at 67.
stopped closed without shipping for issue #783 — its issue is already done deploy ea026b3
Sign in to join this conversation.
new above
offline
Closes #783. For authors: a new migration is a new file,
src/core/migrations/<YYYY-MM-DD-slug>.sql. Never append toschema.ts, whose positional list is now closed at 67.What changed
src/core/schema.ts): the 67 positional migrations becomelegacy-001tolegacy-067, a closed list. After them come the named migrations fromsrc/core/migrations/*.sql, in file-name order.namedMigrationsexports every migration with its name (the forge boots from it).migrationsstays the same list as text, for the code and tests that read it that way. Two pulls that each add a migration add two files, so they don't collide and nobody renumbers by hand.src/kernel/migrate.ts):migrateandopenDbtake named migrations, and failure messages name them.schema_migrationgains anamecolumn (added when missing; older rows keep null). Applied migrations are still identified by a hash of their text (#558), so every legacy migration already applied on a database is recognized unchanged, and a fresh database applies them all in their current order.openDblogs the unknown migrations by name. This is safe because every migration only adds (#875/#902).src/core/releases.jsonnow records which migrations each release shipped (by name, or by count for the legacy-era entry) and locks every migration's text by its id. It's seeded with all 67, which are on main. The release agent runsbun scripts/schema-release.ts <version>when it cuts a release. Running it twice for the same version changes nothing.test/schema-additive.test.tsholds every migration the older of the two newest releases didn't ship to the additive rule, by name instead of count. It also checks that the record names only migrations that exist.Tests (
test/schema-named.test.ts, in the gate):LEGACY_COUNT..sqlfiles, in name order.test/schema-migrations.test.ts's "data ahead of this build is still refused" becomes "data ahead of this build boots". That's the one assertion that changed, and this is why.For pulls in flight that append to the positional list: move the migration into a file under
src/core/migrations/. The legacy-count test tells them so.🤖 Generated with Claude Code