merge: fresh profile reset migration ordering

This commit is contained in:
2026-08-04 15:08:39 +00:00
@@ -1353,23 +1353,9 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
return { status: 'FAILED', detail: 'selected workspace build failed' }; return { status: 'FAILED', detail: 'selected workspace build failed' };
} }
await this.assertProfileSeedCli(workspace.root); await this.assertProfileSeedCli(workspace.root);
const seedInfo = await this.resolveResetSeedInfo( // A newly provisioned profile schema has no world_state row (or table) yet.
profile, // Apply the selected release's migrations before reading optional prior-season
{ // metadata; existing profiles still expose the same season/tick values afterward.
scenarioId,
tickSeconds: tickOverride,
},
profileDatabaseUrl
);
const profileMeta = normalizeMeta(profile.meta);
const nextSeasonIdx = readMetaNumber(profileMeta, 'nextSeasonIdx');
const baseSeason = readMetaNumber(normalizeMeta(seedInfo.meta), 'season');
const season = nextSeasonIdx ?? baseSeason ?? 1;
await updateClaimedProfile({ status: 'STOPPED' }, () =>
this.repository.updateStatus(profile.profileName, 'STOPPED')
);
await this.stopProfile(profile, assertLease);
await assertLease?.();
const migrationResult = await this.runProfileMigration(workspace.root, profileDatabaseUrl); const migrationResult = await this.runProfileMigration(workspace.root, profileDatabaseUrl);
await assertLease?.(); await assertLease?.();
if (!migrationResult.ok) { if (!migrationResult.ok) {
@@ -1388,6 +1374,23 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
); );
return { status: 'FAILED', detail: 'profile database migration failed' }; return { status: 'FAILED', detail: 'profile database migration failed' };
} }
const seedInfo = await this.resolveResetSeedInfo(
profile,
{
scenarioId,
tickSeconds: tickOverride,
},
profileDatabaseUrl
);
const profileMeta = normalizeMeta(profile.meta);
const nextSeasonIdx = readMetaNumber(profileMeta, 'nextSeasonIdx');
const baseSeason = readMetaNumber(normalizeMeta(seedInfo.meta), 'season');
const season = nextSeasonIdx ?? baseSeason ?? 1;
await updateClaimedProfile({ status: 'STOPPED' }, () =>
this.repository.updateStatus(profile.profileName, 'STOPPED')
);
await this.stopProfile(profile, assertLease);
await assertLease?.();
const serverId = buildServerId(profile.profileName, seedTime, installOptions?.installOperationId); const serverId = buildServerId(profile.profileName, seedTime, installOptions?.installOperationId);
const seedResult = await this.runSelectedProfileSeed({ const seedResult = await this.runSelectedProfileSeed({
workspaceRoot: workspace.root, workspaceRoot: workspace.root,