Skip to content

Commit 7bc1ea9

Browse files
authored
Merge pull request #79 from sqlcollaborative/feature/deploy-config-fix
Deploy config fix
2 parents a409c10 + 7d571f4 commit 7bc1ea9

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

bin/deploy.ps1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ $config = Get-DBOConfig -Path "$PSScriptRoot\dbops.config.json" -Configuration $
4242
#Merge custom parameters into a configuration
4343
$newConfig = @{}
4444
foreach ($key in ($PSBoundParameters.Keys)) {
45-
if ($key -in [DBOpsConfig]::EnumProperties()) {
45+
if ($key -in [DBOps.ConfigProperty].GetEnumNames()) {
4646
$newConfig.$key = $PSBoundParameters[$key]
4747
}
4848
}
@@ -62,8 +62,7 @@ foreach ($key in ($PSBoundParameters.Keys)) {
6262

6363
if ($PSCmdlet.ShouldProcess($params.PackageFile, "Initiating the deployment of the package")) {
6464
Invoke-DBODeployment @params
65-
}
66-
else {
65+
} else {
6766
Invoke-DBODeployment @params -WhatIf
6867
}
6968

dbops.psm1

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ Register-PSFConfigValidation -Name "transaction" -ScriptBlock {
2929
try {
3030
if (([string]$Value) -in @('SingleTransaction', 'TransactionPerScript', 'NoTransaction')) {
3131
$Result.Value = [string]$Value
32-
}
33-
else {
32+
} else {
3433
$Result.Message = "Allowed values: SingleTransaction, TransactionPerScript, NoTransaction"
3534
$Result.Success = $False
3635
}
37-
}
38-
catch {
36+
} catch {
3937
$Result.Message = "Failed to convert value to string"
4038
$Result.Success = $False
4139
}
@@ -55,8 +53,7 @@ Register-PSFConfigValidation -Name "securestring" -ScriptBlock {
5553
}
5654
if ($Value -is [securestring]) {
5755
$Result.Value = $Value
58-
}
59-
else {
56+
} else {
6057
$Result.Message = 'Only [securestring] is accepted'
6158
$Result.Success = $False
6259
}
@@ -76,13 +73,11 @@ Register-PSFConfigValidation -Name "hashtable" -ScriptBlock {
7673
try {
7774
if (([hashtable]$Value) -is [hashtable]) {
7875
$Result.Value = [hashtable]$Value
79-
}
80-
else {
76+
} else {
8177
$Result.Message = "Only hashtables are allowed"
8278
$Result.Success = $False
8379
}
84-
}
85-
catch {
80+
} catch {
8681
$Result.Message = "Failed to convert value to hashtable. Only hashtables are allowed."
8782
$Result.Success = $False
8883
}
@@ -103,13 +98,11 @@ Register-PSFConfigValidation -Name "connectionType" -ScriptBlock {
10398
try {
10499
if (([string]$Value) -is [string] -and [string]$Value -in $allowedTypes) {
105100
$Result.Value = [string]$Value
106-
}
107-
else {
101+
} else {
108102
$Result.Message = $failMessage
109103
$Result.Success = $False
110104
}
111-
}
112-
catch {
105+
} catch {
113106
$Result.Message = "Failed to convert value to string. $failMessage"
114107
$Result.Success = $False
115108
}
@@ -157,7 +150,7 @@ if ($typeData) {
157150
$cS = $this.ExecutionManager.ConnectionContext.ConnectionString.Split(';') | Where-Object { $_.Split('=')[0] -ne 'Database' }
158151
$cS += "Database=$($this.Name)"
159152
$connectionString = $cS -join ';'
160-
Invoke-DBODeployment -InputObject $Package -ConnectionString $connectionString
153+
Install-DBOPackage -InputObject $Package -ConnectionString $connectionString
161154
} -ErrorAction Ignore
162155
}
163156
if (!$typeData.Members.ContainsKey('DeployScript')) {
@@ -168,7 +161,7 @@ if ($typeData) {
168161
$cS = $this.ExecutionManager.ConnectionContext.ConnectionString.Split(';') | Where-Object { $_.Split('=')[0] -ne 'Database' }
169162
$cS += "Database=$($this.Name)"
170163
$connectionString = $cS -join ';'
171-
Invoke-DBODeployment -ScriptPath $Path -ConnectionString $connectionString
164+
Install-DBOSqlScript -ScriptPath $Path -ConnectionString $connectionString
172165
} -ErrorAction Ignore
173166
}
174167
}

0 commit comments

Comments
 (0)