You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe "Foreign keys and check constraints not trusted"-Tag FKCKTrusted, Low, Database -ForEach $InstancesToTest {
309
+
$Skip= ($__dbcconfig|Where-Object Name -EQ'skip.database.fkcktrusted').Value
310
+
Context "Testing Foreign Keys and Check Constraints are not trusted <_.Name>" {
311
+
312
+
It "Database <_.Database> Foreign Key <_.Name> on table <_.Parent> should be trusted on <_.SqlInstance>"-Skip:$skip-ForEach $psitem.Databases.Where{ if ($Database) { $_.Name-in$Database } else { $psitem.ConfigValues.fkcktrustedexclude-notcontains$psitem.Name } }.ForeignKeys {
313
+
$psitem.IsChecked| Should -Be $true-Because "This can have a huge performance impact on queries. SQL Server won't use untrusted constraints to build better execution plans. It will also avoid data violation"
314
+
}
315
+
316
+
It "Database <_.Database> Foreign Key <_.Name> on table <_.Parent> should be trusted on <_.SqlInstance>"-Skip:$skip-ForEach $psitem.Databases.Where{ if ($Database) { $_.Name-in$Database } else { $psitem.ConfigValues.fkcktrustedexclude-notcontains$psitem.Name } }.Constraints {
317
+
$psitem.IsChecked| Should -Be $true-Because "This can have a huge performance impact on queries. SQL Server won't use untrusted constraints to build better execution plans. It will also avoid data violation"
Set-PSFConfig-Module dbachecks -Name checks.notv5ready -Value @($__dbachecksNotv5) -Initialize -Description "Checks that have not been converted to v5 yet"
Set-PSFConfig-Module dbachecks -Name policy.autoupdatestatisticsasynchronously.excludedb -Value @() -Initialize -Description "Databases to exclude from the auto update stats asynchronously checks"
255
255
Set-PSFConfig-Module dbachecks -Name policy.database.statusexcludedb -Value @() -Initialize -Description "Databases to exclude from the database status checks"
256
256
Set-PSFConfig-Module dbachecks -Name policy.database.symmetrickeyencryptionlevelexcludedb -Value @('master','msdb','tempdb') -Initialize -Description "Databases to exclude from the Symmetric Key Encryption Level checks"
257
+
Set-PSFConfig-Module dbachecks -Name policy.database.fkcktrustedexclude -Value @() -Initialize -Description "Databases to exclude from the foreign key and constraints trusted checks"
Set-PSFConfig-Module dbachecks -Name skip.database.fkcktrusted -Validation bool -Value $false-Initialize -Description "Skip the check for foreign keys and constraints being trusted"
0 commit comments