-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test-DbaDbCompatibility - Determining target compatibility level based on server version #8992
Conversation
@@ -77,7 +77,8 @@ function Test-DbaDbCompatibility { | |||
Stop-Function -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $instance -Continue | |||
} | |||
|
|||
$serverLevel = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]$server.Databases['master'].CompatibilityLevel | |||
$serverVersion = $server.VersionMajor | |||
$serverLevel = [Microsoft.SqlServer.Management.Smo.CompatibilityLevel]"Version$($serverVersion)0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is itching for bugs to show up if we start assuming it will always be a zero on the end. That is why we use master database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was being done in Set command as well and it was removed because it is unsafe method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we need two internal commands the have a rubust way to translate from MajorVersion to CompatibilityLevel and vice versa. I agree with that. We could then use this in many places...
The question is: Is there an "arithmetic rule" or do we need a switch with hard coded values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/questions/59618625/is-there-a-way-to-query-for-the-supported-compatibility-level-of-a-sql-server suggested using tempdb. That could be a way, will test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused on why we think it is necessary to translate between MajorVersion and Compatibility level. If there was a reason for that then SMO should provide it not us because we are assuming we know the mapping. If we are going to keep a mapping then revert the changes done in Set command and replace that use everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Test-DbaDbCompatibility (Compares Database Compatibility level to Server Compatibility) we need to know the highest possible Compatibility level on that server. So we have the server SMO and need that highest possible Compatibility level. Where do we get that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to know the highest possible value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the test command should tell me, if the database is in the highest possible Compatibility level. Or don't we agree on that one?
And tempdb as well can be set on a different level, so can not be used.
LGTM |
merciiii |
Type of Change
.\tests\manual.pester.ps1
)See issue for details.