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:
Cian Johnston
2026-06-11 15:31:31 +01:00
committed by GitHub
parent b6033aee03
commit a4c867f11b
18 changed files with 683 additions and 10 deletions
+6
View File
@@ -6,6 +6,7 @@ package database
import (
"context"
"database/sql"
"encoding/json"
"time"
@@ -70,6 +71,11 @@ type sqlcQuerier interface {
// created_at ASC flows through to dbpurge's digest truncation; see
// buildDigestData in dbpurge.go for the tradeoff rationale.
AutoArchiveInactiveChats(ctx context.Context, arg AutoArchiveInactiveChatsParams) ([]AutoArchiveInactiveChatsRow, error)
// 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.
BackfillChatModelConfigProvider(ctx context.Context, arg BackfillChatModelConfigProviderParams) (sql.Result, error)
BackoffChatDiffStatus(ctx context.Context, arg BackoffChatDiffStatusParams) error
BatchUpdateWorkspaceAgentMetadata(ctx context.Context, arg BatchUpdateWorkspaceAgentMetadataParams) error
BatchUpdateWorkspaceLastUsedAt(ctx context.Context, arg BatchUpdateWorkspaceLastUsedAtParams) error