Skip to content

Commit

Permalink
Fixes#200 change in syntax, easier to read/parse
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Gallagher committed Aug 28, 2023
1 parent d2d6c5c commit 1c7a336
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plugins/modules/database.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ try {

if ($state -eq "absent") {
if ($null -ne $existingDatabase) {
$droppedDatabase = ($existingDatabase | Remove-DbaDatabase -WhatIf:$checkMode -EnableException -Confirm:$false)
if ($droppedDatabase.Status -eq "Dropped") {
$module.Result.changed = $true
}
elseif ($droppedDatabase.Status -ne "Dropped") {
$module.FailJson("Drop database [$database] failed. " + $droppedDatabase.Status)
try {
$droppedDatabase = $existingDatabase | Remove-DbaDatabase -WhatIf:$checkMode -EnableException -Confirm:$false
if ($droppedDatabase.Status -eq "Dropped") {
$module.Result.changed = $true
}
elseif ($droppedDatabase.Status -ne "Dropped") {
$module.FailJson("Database [$database] was not dropped. " + $droppedDatabase.Status)
}
}
else {
$module.FailJson("Drop database [$database] failed.", $_)
catch {
$module.FailJson("An exception occurred while trying to drop database [$database].", $_)
}
}
$module.ExitJson()
Expand Down

0 comments on commit 1c7a336

Please sign in to comment.