Skip to content

The open alternative to Salesforce, designed for AI.

Fix migration crash: agent.modelId NOT NULL violation (#18844)

Félix Malfait49af5390323c
diff --git a/packages/twenty-server/src/database/typeorm/core/migrations/common/1773900000000-migrate-model-ids-to-composite-format.ts b/packages/twenty-server/src/database/typeorm/core/migrations/common/1773900000000-migrate-model-ids-to-composite-format.ts
index db44450eeb2..e4ae3000371 100644
--- a/packages/twenty-server/src/database/typeorm/core/migrations/common/1773900000000-migrate-model-ids-to-composite-format.ts
+++ b/packages/twenty-server/src/database/typeorm/core/migrations/common/1773900000000-migrate-model-ids-to-composite-format.ts
@@ -25,14 +25,15 @@ export class MigrateModelIdsToCompositeFormat1773900000000
OR array_length("enabledAiModelIds", 1) > 0`,
);
- // Clear agent-specific model IDs so they fall back to workspace defaults
+ // Reset agent model IDs to the sentinel so they fall back to workspace defaults
await queryRunner.query(
- `UPDATE "core"."agent" SET "modelId" = NULL WHERE "modelId" IS NOT NULL`,
+ `UPDATE "core"."agent"
+ SET "modelId" = 'default-smart-model'
+ WHERE "modelId" != 'default-smart-model'`,
);
}
public async down(_queryRunner: QueryRunner): Promise<void> {
- // No reversal needed — sentinel defaults and NULLed agent modelIds
- // are safe to leave in place.
+ // No reversal needed — sentinel defaults are safe to leave in place.
}
}