Skip to content

Commit 151e8ab

Browse files
KM-JADfreddydk
andauthored
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 <freddy.kristiansen@microsoft.com>
1 parent f4cda46 commit 151e8ab

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Misc/Set-BcContainerFeatureKeys.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ try {
7070
}
7171
if ($enabled -ne -1) {
7272
try {
73+
#Create new record in table of feature setup table [Tenant Feature Key] in case it is missing
74+
$SQLRecord = Invoke-Sqlcmd -Database $databaseName -Query "SELECT * FROM [dbo].[Tenant Feature Key] where ID = '$featureKey'"
75+
if ([String]::IsNullOrEmpty($SQLRecord))
76+
{
77+
Write-host -NoNewline "Creating record for feature ID '$featureKey' - "
78+
$SQLcolumns = "ID, Enabled"
79+
$SQLvalues = "'$featureKey',0"
80+
Invoke-Sqlcmd -Database $databaseName -Query "INSERT INTO [CRONUS].[dbo].[Tenant Feature Key]($SQLcolumns) VALUES ($SQLvalues)"
81+
if ($result[0] -eq "1") {
82+
Write-Host " Created"
83+
}
84+
}
7385
Write-Host -NoNewline "Setting feature key $featureKey to $enabledStr - "
7486
$result = Invoke-Sqlcmd -Database $databaseName -Query "UPDATE [dbo].[Tenant Feature Key] set Enabled = $enabled where ID = '$featureKey';Select @@ROWCOUNT"
7587
if ($result[0] -eq "1") {

0 commit comments

Comments
 (0)