mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: backfill legacy Bedrock AI provider rows and stale model config strings (#26155)
Fixes CODAGT-548
Adds two idempotent startup backfills run after `newAPI():
- `BackfillBedrockProviderType`: promotes `ai_providers` rows from
`type=anthropic` with Bedrock settings to `type=bedrock`.
- `BackfillChatModelConfigProviderStrings`: fixes stale
`chat_model_configs.provider = "anthropic"` strings on rows whose linked
provider was just promoted.
- `UpdateAIProvider` query now also writes the `type` column, so the
fix persists on any subsequent PATCH.
> 🤖 Generated by Claude with oversight from a human.
This commit is contained in:
@@ -66,6 +66,7 @@ RETURNING
|
||||
UPDATE
|
||||
ai_providers
|
||||
SET
|
||||
type = @type::ai_provider_type,
|
||||
display_name = sqlc.narg('display_name')::text,
|
||||
enabled = @enabled::boolean,
|
||||
base_url = @base_url::text,
|
||||
|
||||
@@ -144,6 +144,27 @@ WHERE
|
||||
provider = @provider::text
|
||||
AND deleted = FALSE;
|
||||
|
||||
-- name: BackfillChatModelConfigProvider :execresult
|
||||
-- old_provider is matched as text; new_provider is also cast to ai_provider_type
|
||||
-- for the EXISTS check against ai_providers.type.
|
||||
-- ai_provider_id IS NOT NULL is defensive; the check constraint already
|
||||
-- enforces that non-deleted rows always have a provider ID.
|
||||
UPDATE
|
||||
chat_model_configs
|
||||
SET
|
||||
provider = @new_provider::text,
|
||||
updated_at = NOW()
|
||||
WHERE
|
||||
provider = @old_provider::text
|
||||
AND deleted = FALSE
|
||||
AND ai_provider_id IS NOT NULL
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM ai_providers
|
||||
WHERE id = chat_model_configs.ai_provider_id
|
||||
AND type = @new_provider::ai_provider_type
|
||||
AND deleted = FALSE
|
||||
);
|
||||
|
||||
-- name: DeleteChatModelConfigsByAIProviderID :exec
|
||||
UPDATE
|
||||
chat_model_configs
|
||||
|
||||
Reference in New Issue
Block a user