Skip to content

Commit

Permalink
Fix - creation of missing reccord in table [Tenant Feature Key] (#3658)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KM-JAD and freddydk authored Sep 9, 2024
1 parent f4cda46 commit 151e8ab
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Misc/Set-BcContainerFeatureKeys.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 151e8ab

Please sign in to comment.