File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,24 @@ function Invoke-EnsureDatabase {
18
18
return
19
19
}
20
20
$targetDB = $csBuilder.Database
21
- $csBuilder.Database = ' mysql '
21
+ $csBuilder.Database = ' sys '
22
22
$dbExistsQuery = " SELECT SCHEMA_NAME AS 'Database' FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$targetDB '"
23
- $dbExists = Invoke-DBOQuery - Type $Type - ConnectionString $csBuilder - Query $dbExistsQuery
23
+ try {
24
+ $dbExists = Invoke-DBOQuery - Type $Type - ConnectionString $csBuilder - Query $dbExistsQuery
25
+ }
26
+ catch {
27
+ $Log.WriteError (" Unable to check database existance on {0}: {1}" , @ ($csBuilder.Server , $csBuilder.Database ));
28
+ throw $_
29
+ }
24
30
if (-not $dbExists.Database ) {
25
31
$query = ' CREATE DATABASE `{0}`' -f $targetDB
26
- $null = Invoke-DBOQuery - Type $Type - ConnectionString $csBuilder - Query $query
32
+ try {
33
+ $null = Invoke-DBOQuery - Type $Type - ConnectionString $csBuilder - Query $query
34
+ }
35
+ catch {
36
+ $Log.WriteError (" Unable to create database {0} on {1}" , @ ($csBuilder.Database , $csBuilder.Server ));
37
+ throw $_
38
+ }
27
39
$Log.WriteInformation (" Created database {0}" , $targetDB )
28
40
}
29
41
}
You can’t perform that action at this time.
0 commit comments