feat(migrations)!: align runMemoryMigrations with runMigrations - #54
Merged
TheGreatAxios merged 1 commit intoSep 27, 2026
Conversation
TheGreatAxios
commented
Sep 25, 2026
TheGreatAxios
left a comment
Contributor
Author
There was a problem hiding this comment.
Self-review, four passes over the stacked range.
Verdict: ready for review.
- Replays are idempotent on real Postgres, including a database migrated by the old runner.
- The host-schema rewrite matches Interchange's regex, and a foreign key into a different host schema fails the replay.
- Waivers and the type-only
DBConfignote are in the description.
TheGreatAxios
force-pushed
the
cl-9138-memory-align-runmemorymigrations-to-runmigrationsconfig
branch
from
September 25, 2026 07:02
f46acf8 to
c005288
Compare
TheGreatAxios
force-pushed
the
cl-9138-memory-align-runmemorymigrations-to-runmigrationsconfig
branch
from
September 25, 2026 18:31
c005288 to
31a6be6
Compare
TheGreatAxios
force-pushed
the
cl-9138-memory-align-runmemorymigrations-to-runmigrationsconfig
branch
from
September 26, 2026 01:32
31a6be6 to
3cb8b97
Compare
TheGreatAxios
force-pushed
the
cl-9138-memory-align-runmemorymigrations-to-runmigrationsconfig
branch
from
September 26, 2026 01:36
3cb8b97 to
63abc3d
Compare
TheGreatAxios
added this pull request to stack #61
September 26, 2026 01:57
runMemoryMigrations(config, { schema, ftsLanguage }) takes the same
DBConfig and schema as Interchange runMigrations. schema names the host
schema holding the tenant and principal tables, and the foreign-key
references in the SQL are rewritten to it; memory's own tables stay in
the memory schema. The runner replays every migration file on each run
instead of keeping a memory._migrations ledger, which a new migration
drops. Foreign keys and CHECK constraints are added only when missing,
so a replay does not re-validate tables, a lock timeout keeps a replay
from stalling readers, and the one-time temporal_class backfill runs
only in the replay that adds the column. ftsLanguage is required, with
no default, and the runner no longer reads FTS_LANGUAGE from the
environment.
TheGreatAxios
force-pushed
the
cl-9138-memory-align-runmemorymigrations-to-runmigrationsconfig
branch
from
September 27, 2026 00:32
63abc3d to
a867f83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #53; merge that first.
runMemoryMigrations(config, { schema, ftsLanguage })takes the sameDBConfigandschemaas InterchangerunMigrations.schemais the host schema holding thetenantandprincipaltables; the"public".foreign-key references are rewritten to it. Memory's own tables stay in thememoryschema.memory._migrations. Foreign keys and CHECK constraints are added only when missing. A foreign key that points at a different host schema fails the replay. Thetemporal_classbackfill runs only in the replay that adds the column.pg_advisory_xact_lock, the same approach as@corbits/artifacts, so replicas that boot together run it one at a time instead of racingCREATE ... IF NOT EXISTSor deadlocking. There is nolock_timeout, matching artifacts: a replay waits behind a long reader instead of failing boot, and a failed replay rolls back whole and releases the lock.ftsLanguageis required, with no default. The runner no longer readsFTS_LANGUAGEfrom the environment.configis checked by type only:@intx/db0.4.0 exportsDBConfigas a type, not a validator.@intx/dbis a required peer becauseDBConfigis part of the signature.Verification
bun run typecheckandbun test ./srcpass (457 tests).public,huband a quoted name. The foreign keys target<schema>.tenant/principal. A database migrated by the 0.1.0 runner upgrades cleanly and loses its ledger.Closes CL-9138
Closes CL-9143
Closes CL-9180