fix(migration): preserve _migrations in config when sidecar write fails

This commit is contained in:
YeonGyu-Kim
2026-04-10 18:47:18 +09:00
parent 10371d5bde
commit 68c8701d34
2 changed files with 33 additions and 2 deletions
+3 -2
View File
@@ -74,12 +74,13 @@ export function migrateConfigFile(
// the first place. The in-memory `rawConfig` never re-exposes
// `_migrations` to downstream schema validation.
const newMigrationsToRecord = allNewMigrations.filter(mKey => !existingMigrations.has(mKey))
let sidecarWriteSucceeded = false
if (newMigrationsToRecord.length > 0 || hadLegacyInConfigMigrations) {
const fullMigrationSet = new Set<string>([
...existingMigrations,
...newMigrationsToRecord,
])
writeAppliedMigrations(configPath, fullMigrationSet)
sidecarWriteSucceeded = writeAppliedMigrations(configPath, fullMigrationSet)
}
if (newMigrationsToRecord.length > 0) {
needsWrite = true
@@ -88,7 +89,7 @@ export function migrateConfigFile(
// Migrating state out of the config body is itself a config write.
needsWrite = true
}
if ("_migrations" in copy) {
if (sidecarWriteSucceeded && "_migrations" in copy) {
delete copy._migrations
}