Skip to content

Commit c709a82

Browse files
shivamhwpclaude
authored andcommitted
refactor(server): share the V2 migration cap check
Refine pass: one flag gates both preview reconciliation and the V2 id check. Co-Authored-By: Claude Fable 5.1 <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent a5403f9 commit c709a82

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎apps/server/src/persistence/Migrations.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ export interface RunMigrationsOptions {
211211
export const runMigrations = Effect.fn("runMigrations")(function* ({
212212
toMigrationInclusive,
213213
}: RunMigrationsOptions = {}) {
214-
const previewMigrations =
215-
toMigrationInclusive === undefined || toMigrationInclusive >= FIRST_V2_MIGRATION_ID
216-
? yield* reconcileV2PreviewMigration()
217-
: [];
218-
if (toMigrationInclusive === undefined || toMigrationInclusive >= FIRST_V2_MIGRATION_ID) {
214+
const includesV2 =
215+
toMigrationInclusive === undefined || toMigrationInclusive >= FIRST_V2_MIGRATION_ID;
216+
const previewMigrations = includesV2 ? yield* reconcileV2PreviewMigration() : [];
217+
if (includesV2) {
219218
yield* assertV2MigrationsCanRun();
220219
}
221220
const executedMigrations = [

‎docs/internals/legacy-orchestration-migration.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ local or fork migration under an id this build later assigns to a different migr
4949
never receives this build's migration at that id. For ids 55 and up, which hold V2's own schema,
5050
`runMigrations` refuses to start before migrating, because V2 cannot run without them. Below 55 it
5151
only logs each recorded id whose name differs from the manifest, since real databases carry
52-
site-local migrations there and still work. There is no safe id range
53-
for a fork inside this ledger: any id at or below a future upstream id masks it forever, so fork
54-
schema changes belong in a separate migration table or outside the migrator entirely.
52+
site-local migrations there and still work. There is no safe id range for a fork inside this
53+
ledger: any id at or below a future upstream id masks it forever, so fork schema changes belong in
54+
a separate migration table or outside the migrator entirely.
5555

5656
## Recovery
5757

0 commit comments

Comments
 (0)