From 151e8ab2b9b8e289c5b1dd601e3854d707f7494c Mon Sep 17 00:00:00 2001 From: KM-JAD <81407981+KM-JAD@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:52:50 +0200 Subject: [PATCH] Fix - creation of missing reccord in table [Tenant Feature Key] (#3658) In case that related record in SQL table [dbo].[Tenant Feature Key] is missing, it is created automaticaly and then updated by this script as usual. Co-authored-by: Freddy Kristiansen --- Misc/Set-BcContainerFeatureKeys.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Misc/Set-BcContainerFeatureKeys.ps1 b/Misc/Set-BcContainerFeatureKeys.ps1 index 6c2e27c2f..ad8b0e8f9 100644 --- a/Misc/Set-BcContainerFeatureKeys.ps1 +++ b/Misc/Set-BcContainerFeatureKeys.ps1 @@ -70,6 +70,18 @@ try { } if ($enabled -ne -1) { try { + #Create new record in table of feature setup table [Tenant Feature Key] in case it is missing + $SQLRecord = Invoke-Sqlcmd -Database $databaseName -Query "SELECT * FROM [dbo].[Tenant Feature Key] where ID = '$featureKey'" + if ([String]::IsNullOrEmpty($SQLRecord)) + { + Write-host -NoNewline "Creating record for feature ID '$featureKey' - " + $SQLcolumns = "ID, Enabled" + $SQLvalues = "'$featureKey',0" + Invoke-Sqlcmd -Database $databaseName -Query "INSERT INTO [CRONUS].[dbo].[Tenant Feature Key]($SQLcolumns) VALUES ($SQLvalues)" + if ($result[0] -eq "1") { + Write-Host " Created" + } + } Write-Host -NoNewline "Setting feature key $featureKey to $enabledStr - " $result = Invoke-Sqlcmd -Database $databaseName -Query "UPDATE [dbo].[Tenant Feature Key] set Enabled = $enabled where ID = '$featureKey';Select @@ROWCOUNT" if ($result[0] -eq "1") {