Hello Clint,
This SQL will copy any credentials that BuildMaster has but Otter doesn't to Otter. However, it will not work if BuildMaster and Otter use different encryption keys. You can find the encryption keys for BuildMaster and Otter in app_appSettings.config and in web_appSettings.config. The key will look like this in the file: <add key="Persistence.EncryptionKey" value="[encryption key is here]" />
INSERT INTO [Otter].[dbo].[Credentials] ([Environment_Id], [Credential_Name], [CredentialType_Name], [LegacyConfiguration_Bytes], [Configuration_Xml], [AllowFunctionAccess_Indicator])
-- Omit the line above this comment to test this before running it for real
SELECT OE.[Environment_Id]
,BC.[Credential_Name]
,BC.[CredentialType_Name]
,[LegacyConfiguration_Bytes] = NULL
,[Configuration_Xml] = CAST(REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
CAST(BC.[Configuration_Xml] AS VARCHAR(MAX)),
'<Inedo.BuildMaster.Extensibility.Credentials.BuildMasterCredentials Assembly="BuildMasterCore">',
'<Inedo.Otter.Extensions.Credentials.BuildMasterCredentials Assembly="OtterCore">'
),
'<Inedo.BuildMaster.Extensibility.Credentials.OtterCredentials Assembly="BuildMasterCore">',
'<Inedo.Otter.Extensions.Credentials.OtterCredentials Assembly="OtterCore">'
),
'<Inedo.BuildMaster.Extensibility.Credentials.ProGetCredentials Assembly="BuildMasterCore">',
'<Inedo.Otter.Extensions.Credentials.ProGetCredentials Assembly="OtterCore">'
),
'<Inedo.BuildMaster.Extensibility.Credentials.PrivateKeyCredentials Assembly="BuildMasterCore">',
'<Inedo.Otter.Extensions.Credentials.PrivateKeyCredentials Assembly="OtterCore">'
),
'<Inedo.BuildMaster.Extensibility.Credentials.UsernamePasswordCredentials Assembly="BuildMasterCore">',
'<Inedo.Otter.Extensions.Credentials.UsernamePasswordCredentials Assembly="OtterCore">'
),
'</Inedo.BuildMaster.Extensibility.Credentials.BuildMasterCredentials>',
'</Inedo.Otter.Extensions.Credentials.BuildMasterCredentials>'
),
'</Inedo.BuildMaster.Extensibility.Credentials.OtterCredentials>',
'</Inedo.Otter.Extensions.Credentials.OtterCredentials>'
),
'</Inedo.BuildMaster.Extensibility.Credentials.ProGetCredentials>',
'</Inedo.Otter.Extensions.Credentials.ProGetCredentials>'
),
'</Inedo.BuildMaster.Extensibility.Credentials.PrivateKeyCredentials>',
'</Inedo.Otter.Extensions.Credentials.PrivateKeyCredentials>'
),
'</Inedo.BuildMaster.Extensibility.Credentials.UsernamePasswordCredentials>',
'</Inedo.Otter.Extensions.Credentials.UsernamePasswordCredentials>'
) AS XML)
,BC.[AllowFunctionAccess_Indicator]
FROM [BuildMaster].[dbo].[Credentials] BC
LEFT OUTER JOIN [Otter].[dbo].[Credentials] OC
ON BC.[Credential_Name] = OC.[Credential_Name]
LEFT OUTER JOIN [BuildMaster].[dbo].[Environments] BE
ON BC.[Environment_Id] = BE.[Environment_Id]
LEFT OUTER JOIN [Otter].[dbo].[Environments] OE
ON BE.[Environment_Name] = OE.[Environment_Name]
WHERE OC.[Credential_Id] IS NULL