MERGE [dbo].[Workspaces] AS T
    USING (VALUES (@Id, @Name, @HasHITL, @HITLProvider, @MinimumConfidenceThreshold, @PausePrFeedbackBeforeRouting,
    @ReviewSlaMinutes, @MaxAutoRetryOnRejection, @DefaultBranch, @VersionControlBranchPrefix, @RepositoryUrl, @VersionControlToken,
    @VersionControlSystem, @VersionControlAuthType, @VersionControlProvider, @VersionControlUserName, @VersionControlUserEmail,
    @VersionControlApiBaseUrl, @VersionControlApiVersion, @CodeReviewSystem, @AzureOpenAiEndpoint,
    @AzureOpenAiApiKey, @AzureOpenAiDeployment, @InviteTokenTtl, @InviteAcceptBaseUrl,
    @InviteEmailSubjectTemplate, @InviteEmailBodyTemplate, @PullRequestDescriptionTemplate,
    @PullRequestCommentTemplate, @EmailFrom, @EmailTo, @EmailSmtpHost, @EmailSmtpPort, @EmailSmtpUsername,
    @EmailSmtpPassword, @EmailSmtpUseSsl, @SlackWebhookUrl, @SlackChannel, @SlackBotName, @SlackIconEmoji,
    @SlackMessageTemplate, @TeamsWebhookUrl, @TeamsMessageTemplate, @ObservabilitySystem,
    @ObservabilityApiKey, @CiCdSystem, @CiCdApiKey, @HostingProvider, @TenantId,
    @VersionControlConnectedAtUtc, @VersionControlConnectionState, @VersionControlLastTestError,
    @VersionControlLastTestedAtUtc, @UseCoffeeBreakReviewerPool, @IsEnabled)) AS S([Id], [Name], [HasHITL],
    [HITLProvider],
    [MinimumConfidenceThreshold],
    [PausePrFeedbackBeforeRouting],
    [ReviewSlaMinutes],
    [MaxAutoRetryOnRejection],
    [DefaultBranch],
    [VersionControlBranchPrefix],
    [RepositoryUrl],
    [VersionControlToken],
    [VersionControlSystem],
    [VersionControlAuthType],
    [VersionControlProvider],
    [VersionControlUserName],
    [VersionControlUserEmail],
    [VersionControlApiBaseUrl],
    [VersionControlApiVersion],
    [CodeReviewSystem],
    [AzureOpenAiEndpoint],
    [AzureOpenAiApiKey],
    [AzureOpenAiDeployment],
    [InviteTokenTtl],
    [InviteAcceptBaseUrl],
    [InviteEmailSubjectTemplate],
    [InviteEmailBodyTemplate],
    [PullRequestDescriptionTemplate],
    [PullRequestCommentTemplate],
    [EmailFrom], [EmailTo],
    [EmailSmtpHost],
    [EmailSmtpPort],
    [EmailSmtpUsername],
    [EmailSmtpPassword],
    [EmailSmtpUseSsl],
    [SlackWebhookUrl],
    [SlackChannel],
    [SlackBotName],
    [SlackIconEmoji],
    [SlackMessageTemplate],
    [TeamsWebhookUrl],
    [TeamsMessageTemplate],
    [ObservabilitySystem],
    [ObservabilityApiKey],
    [CiCdSystem],
    [CiCdApiKey],
    [HostingProvider],
    [TenantId],
    [VersionControlConnectedAtUtc],
    [VersionControlConnectionState],
    [VersionControlLastTestError],
    [VersionControlLastTestedAtUtc],
    [UseCoffeeBreakReviewerPool],
    [IsEnabled])
    ON T.[Id] = S.[Id]
    WHEN MATCHED THEN
UPDATE
    SET T.[Name] = S.[Name],
    T.[HasHITL] = S.[HasHITL],
    T.[HITLProvider] = S.[HITLProvider],
    T.[MinimumConfidenceThreshold] = S.[MinimumConfidenceThreshold],
    T.[PausePrFeedbackBeforeRouting] = S.[PausePrFeedbackBeforeRouting],
    T.[ReviewSlaMinutes] = S.[ReviewSlaMinutes],
    T.[MaxAutoRetryOnRejection] = S.[MaxAutoRetryOnRejection],
    T.[DefaultBranch] = S.[DefaultBranch],
    T.[VersionControlBranchPrefix] = S.[VersionControlBranchPrefix],
    T.[RepositoryUrl] = S.[RepositoryUrl],
    T.[VersionControlToken] = S.[VersionControlToken],
    T.[VersionControlSystem] = S.[VersionControlSystem],
    T.[VersionControlAuthType] = S.[VersionControlAuthType],
    T.[VersionControlProvider] = S.[VersionControlProvider],
    T.[VersionControlUserName] = S.[VersionControlUserName],
    T.[VersionControlUserEmail] = S.[VersionControlUserEmail],
    T.[VersionControlApiBaseUrl] = S.[VersionControlApiBaseUrl],
    T.[VersionControlApiVersion] = S.[VersionControlApiVersion],
    T.[CodeReviewSystem] = S.[CodeReviewSystem],
    T.[AzureOpenAiEndpoint] = S.[AzureOpenAiEndpoint],
    T.[AzureOpenAiApiKey] = S.[AzureOpenAiApiKey],
    T.[AzureOpenAiDeployment] = S.[AzureOpenAiDeployment],
    T.[InviteTokenTtl] = S.[InviteTokenTtl],
    T.[InviteAcceptBaseUrl] = S.[InviteAcceptBaseUrl],
    T.[InviteEmailSubjectTemplate] = S.[InviteEmailSubjectTemplate],
    T.[InviteEmailBodyTemplate] = S.[InviteEmailBodyTemplate],
    T.[PullRequestDescriptionTemplate] = S.[PullRequestDescriptionTemplate],
    T.[PullRequestCommentTemplate] = S.[PullRequestCommentTemplate],
    T.[EmailFrom] = S.[EmailFrom],
    T.[EmailTo] = S.[EmailTo],
    T.[EmailSmtpHost] = S.[EmailSmtpHost],
    T.[EmailSmtpPort] = S.[EmailSmtpPort],
    T.[EmailSmtpUsername] = S.[EmailSmtpUsername],
    T.[EmailSmtpPassword] = S.[EmailSmtpPassword],
    T.[EmailSmtpUseSsl] = S.[EmailSmtpUseSsl],
    T.[SlackWebhookUrl] = S.[SlackWebhookUrl],
    T.[SlackChannel] = S.[SlackChannel],
    T.[SlackBotName] = S.[SlackBotName],
    T.[SlackIconEmoji] = S.[SlackIconEmoji],
    T.[SlackMessageTemplate] = S.[SlackMessageTemplate],
    T.[TeamsWebhookUrl] = S.[TeamsWebhookUrl],
    T.[TeamsMessageTemplate] = S.[TeamsMessageTemplate],
    T.[ObservabilitySystem] = S.[ObservabilitySystem],
    T.[ObservabilityApiKey] = S.[ObservabilityApiKey],
    T.[CiCdSystem] = S.[CiCdSystem],
    T.[CiCdApiKey] = S.[CiCdApiKey],
    T.[HostingProvider] = S.[HostingProvider],
    T.[TenantId] = S.[TenantId],
    T.[VersionControlConnectedAtUtc] = S.[VersionControlConnectedAtUtc],
    T.[VersionControlConnectionState] = S.[VersionControlConnectionState],
    T.[VersionControlLastTestError] = S.[VersionControlLastTestError],
    T.[VersionControlLastTestedAtUtc] = S.[VersionControlLastTestedAtUtc],
    T.[UseCoffeeBreakReviewerPool] = S.[UseCoffeeBreakReviewerPool],
    T.[IsEnabled] = S.[IsEnabled]
    WHEN NOT MATCHED THEN
INSERT
(
[Id],
[Name],
[HasHITL],
[HITLProvider],
[MinimumConfidenceThreshold],
[PausePrFeedbackBeforeRouting],
[ReviewSlaMinutes],
[MaxAutoRetryOnRejection],
[DefaultBranch],
[VersionControlBranchPrefix],
[RepositoryUrl],
[VersionControlToken],
[VersionControlSystem],
[VersionControlAuthType],
[VersionControlProvider],
[VersionControlUserName],
[VersionControlUserEmail],
[VersionControlApiBaseUrl],
[VersionControlApiVersion],
[CodeReviewSystem],
[AzureOpenAiEndpoint],
[AzureOpenAiApiKey],
[AzureOpenAiDeployment],
[InviteTokenTtl],
[InviteAcceptBaseUrl],
[InviteEmailSubjectTemplate],
[InviteEmailBodyTemplate],
[PullRequestDescriptionTemplate],
[PullRequestCommentTemplate],
[EmailFrom],
[EmailTo],
[EmailSmtpHost],
[EmailSmtpPort],
[EmailSmtpUsername],
[EmailSmtpPassword],
[EmailSmtpUseSsl],
[SlackWebhookUrl],
[SlackChannel],
[SlackBotName],
[SlackIconEmoji],
[SlackMessageTemplate],
[TeamsWebhookUrl],
[TeamsMessageTemplate],
[ObservabilitySystem],
[ObservabilityApiKey],
[CiCdSystem],
[CiCdApiKey],
[HostingProvider],
[TenantId],
[VersionControlConnectedAtUtc],
[VersionControlConnectionState],
[VersionControlLastTestError],
[VersionControlLastTestedAtUtc],
[UseCoffeeBreakReviewerPool],
[IsEnabled])
VALUES (S.[Id], S.[Name], S.[HasHITL], S.[HITLProvider], S.[MinimumConfidenceThreshold], S.[PausePrFeedbackBeforeRouting], 
S.[ReviewSlaMinutes], S.[MaxAutoRetryOnRejection], S.[DefaultBranch], S.[VersionControlBranchPrefix], S.[RepositoryUrl], S.[VersionControlToken], 
S.[VersionControlSystem], S.[VersionControlAuthType], S.[VersionControlProvider], S.[VersionControlUserName], S.[VersionControlUserEmail], S.[VersionControlApiBaseUrl], 
S.[VersionControlApiVersion], S.[CodeReviewSystem], S.[AzureOpenAiEndpoint], S.[AzureOpenAiApiKey], S.[AzureOpenAiDeployment], S.[InviteTokenTtl], S.[InviteAcceptBaseUrl], 
S.[InviteEmailSubjectTemplate], S.[InviteEmailBodyTemplate], S.[PullRequestDescriptionTemplate], S.[PullRequestCommentTemplate], S.[EmailFrom], S.[EmailTo], 
S.[EmailSmtpHost], S.[EmailSmtpPort], S.[EmailSmtpUsername], S.[EmailSmtpPassword], S.[EmailSmtpUseSsl], S.[SlackWebhookUrl], S.[SlackChannel], S.[SlackBotName], 
S.[SlackIconEmoji], S.[SlackMessageTemplate], S.[TeamsWebhookUrl], S.[TeamsMessageTemplate], S.[ObservabilitySystem], S.[ObservabilityApiKey], S.[CiCdSystem], 
S.[CiCdApiKey], S.[HostingProvider], S.[TenantId], S.[VersionControlConnectedAtUtc], S.[VersionControlConnectionState], S.[VersionControlLastTestError], 
S.[VersionControlLastTestedAtUtc], S.[UseCoffeeBreakReviewerPool], S.[IsEnabled]);
