-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialize-Lab.ps1
More file actions
60 lines (45 loc) · 1.62 KB
/
Copy pathInitialize-Lab.ps1
File metadata and controls
60 lines (45 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Requires -Version 7.0
[CmdletBinding()]
param(
[ValidateRange(30, 600)]
[int]$TimeoutSeconds = 180,
[switch]$SkipImagePull
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'SqlServerLab.Common.ps1')
Write-Host 'Validating Docker and local configuration...'
Assert-DockerReady
Assert-LabConfiguration
if (-not $SkipImagePull) {
Write-Host 'Pulling the configured SQL Server image...'
Invoke-ComposeCommand -Arguments @('pull', $script:SqlServerService)
}
Write-Host 'Starting SQL Server...'
Invoke-ComposeCommand -Arguments @('up', '-d', $script:SqlServerService)
Wait-SqlServerHealthy -TimeoutSeconds $TimeoutSeconds
$coreScripts = @(
'sql/01_create_database.sql'
'sql/02_create_schema.sql'
'sql/03_insert_sample_data.sql'
'sql/07_create_reporting_model.sql'
'sql/08_load_reporting_model.sql'
'sql/04_analysis_queries.sql'
)
Write-Host 'Running the ordered database workflow...'
& (Join-Path $PSScriptRoot 'Invoke-SqlScript.ps1') -Path $coreScripts
Write-Host 'Verifying the resulting database state...'
& (Join-Path $PSScriptRoot 'Test-LabConnection.ps1')
Write-Host 'Testing enforced data-integrity rules...'
& (Join-Path $PSScriptRoot 'Test-DataIntegrity.ps1')
Write-Host 'Verifying the dimensional reporting model...'
& (Join-Path $PSScriptRoot 'Test-ReportingModel.ps1')
$port = Get-DotEnvValue -Path $script:EnvironmentFile -Name 'MSSQL_PORT'
if ([string]::IsNullOrWhiteSpace($port)) {
$port = '14333'
}
Write-Host ''
Write-Host 'SQL Server lab is ready.'
Write-Host "Server: 127.0.0.1,$port"
Write-Host 'Database: dpa_training'
Write-Host 'User: sa'