Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param
- (
- [Parameter(Mandatory=$true)]
- [string]$PackageFilePathPattern = $null,
- [Parameter(Mandatory=$true)]
- [string]$DatabaseDeploymentResourcesPath = $null,
- [Parameter(Mandatory=$true)]
- [string]$DatabaseServer = $null,
- [Parameter(Mandatory=$true)]
- [string]$DatabaseName = $null,
- [Parameter(Mandatory=$false)]
- [string]$DatabaseUserName = $null,
- [Parameter(Mandatory=$false)]
- [string]$DatabasePassword = $null
- )
- $ErrorActionPreference = "Stop"
- # Match the package file name. Only one file should match
- $possiblePackageFiles = (Get-ChildItem $PackageFilePathPattern)
- if ($possiblePackageFiles.Count -ne 1)
- {
- [string]$message = "Error: " + $possiblePackageFiles.Count.ToString() + " files match. Precisely 1 file should match pattern."
- throw [System.Exception] $message
- }
- $PackageFilePath = $possiblePackageFiles.FullName
- $PackageFileNameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($PackageFilePath)
- # Combine deployment path with NuGet package name for unique directory
- $DatabaseDeploymentResourcesPath = Join-Path $DatabaseDeploymentResourcesPath $PackageFileNameWithoutExtension
- # Create connection string
- $targetDb = New-DlmDatabaseConnection -ServerInstance $DatabaseServer -Database $DatabaseName -Username $DatabaseUserName -Password $DatabasePassword | Test-DlmDatabaseConnection
- # Stop on any warnings
- $highWarnings = $databaseUpdate.Warnings | Where { $_.Severity -eq "High" }
- if($highWarnings.Count -gt 0)
- {
- [string]$highWarningsDetails = ""
- $highWarnings | ForEach-Object { $highWarningsDetails = $highWarningsDetails + $_.Details + "`n" }
- throw [System.Exception] $highWarningsDetails
- }
- # Update target from database release object
- Import-DlmDatabaseRelease $DatabaseDeploymentResourcesPath | Use-DlmDatabaseRelease -DeployTo $targetDb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement