fix: isolate minimax m3 backend migration

This commit is contained in:
Codex
2026-06-02 08:11:15 +08:00
parent ab40d86dde
commit 4b9dc79b67
4 changed files with 28 additions and 5 deletions
+9 -2
View File
@@ -102,8 +102,15 @@ export function backendCapabilities(): JsonRecord[] {
return backendProfileSpecs.map(backendCapability);
}
export function backendCapabilitiesSqlValues(): string {
return backendProfileSpecs.map((spec) => {
export function backendCapabilitiesSqlValues(profiles?: readonly BackendProfile[]): string {
const specs = profiles
? profiles.map((profile) => {
const spec = backendProfileSpec(profile);
if (!spec) throw new Error(`unknown backend profile for SQL seed: ${profile}`);
return spec;
})
: backendProfileSpecs;
return specs.map((spec) => {
const capabilities = JSON.stringify({
backendKind: spec.backendKind,
protocol: spec.protocol,
+16 -1
View File
@@ -119,7 +119,17 @@ ON CONFLICT (profile) DO UPDATE SET
const backendProfilesMigrationSql = `
INSERT INTO agentrun_backends (profile, capabilities, capacity, health, updated_at)
VALUES ${backendCapabilitiesSqlValues()}
VALUES ${backendCapabilitiesSqlValues(["codex", "deepseek"])}
ON CONFLICT (profile) DO UPDATE SET
capabilities = EXCLUDED.capabilities,
capacity = EXCLUDED.capacity,
health = EXCLUDED.health,
updated_at = EXCLUDED.updated_at;
`;
const minimaxM3BackendProfileMigrationSql = `
INSERT INTO agentrun_backends (profile, capabilities, capacity, health, updated_at)
VALUES ${backendCapabilitiesSqlValues(["minimax-m3"])}
ON CONFLICT (profile) DO UPDATE SET
capabilities = EXCLUDED.capabilities,
capacity = EXCLUDED.capacity,
@@ -239,6 +249,11 @@ const postgresMigrations: MigrationDefinition[] = [
checksum: checksumSql(queueQ1MigrationSql),
sql: queueQ1MigrationSql,
},
{
id: "005_v01_minimax_m3_backend_profile",
checksum: checksumSql(minimaxM3BackendProfileMigrationSql),
sql: minimaxM3BackendProfileMigrationSql,
},
];
export function postgresMigrationContract(): JsonRecord {
+2 -1
View File
@@ -13,7 +13,8 @@ const selfTest: SelfTestCase = async () => {
(error) => error instanceof AgentRunError && error.failureKind === "infra-failed" && error.message.includes("DATABASE_URL is required"),
);
const postgresContract = postgresMigrationContract();
assert.equal(postgresContract.latestMigrationId, "004_v01_queue_q1");
assert.equal(postgresContract.latestMigrationId, "005_v01_minimax_m3_backend_profile");
assert.equal((postgresContract.checksums as Record<string, string>)["002_v01_backend_profiles"], "928b5c490cc4539cb64ecef34784557601b2724fa2870570f16a53576804e49c");
assert.ok(Array.isArray(postgresContract.requiredTables));
assert.ok(postgresContract.requiredTables.includes("agentrun_schema_migrations"));
assert.ok(postgresContract.requiredTables.includes("agentrun_runs"));