Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. param
  2. (
  3. [Parameter(Mandatory=$true)]
  4. [string]$PackageFilePathPattern = $null,
  5. [Parameter(Mandatory=$true)]
  6. [string]$DatabaseDeploymentResourcesPath = $null,
  7. [Parameter(Mandatory=$true)]
  8. [string]$DatabaseServer = $null,
  9. [Parameter(Mandatory=$true)]
  10. [string]$DatabaseName = $null,
  11. [Parameter(Mandatory=$false)]
  12. [string]$DatabaseUserName = $null,
  13. [Parameter(Mandatory=$false)]
  14. [string]$DatabasePassword = $null
  15. )
  16.  
  17. $ErrorActionPreference = "Stop"
  18.  
  19. # Match the package file name. Only one file should match
  20. $possiblePackageFiles = (Get-ChildItem $PackageFilePathPattern)
  21. if ($possiblePackageFiles.Count -ne 1)
  22. {
  23. [string]$message = "Error: " + $possiblePackageFiles.Count.ToString() + " files match. Precisely 1 file should match pattern."
  24. throw [System.Exception] $message
  25. }
  26. $PackageFilePath = $possiblePackageFiles.FullName
  27.  
  28. $PackageFileNameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($PackageFilePath)
  29.  
  30. # Combine deployment path with NuGet package name for unique directory
  31.  
  32. $DatabaseDeploymentResourcesPath = Join-Path $DatabaseDeploymentResourcesPath $PackageFileNameWithoutExtension
  33.  
  34. # Create connection string
  35. $targetDb = New-DlmDatabaseConnection -ServerInstance $DatabaseServer -Database $DatabaseName -Username $DatabaseUserName -Password $DatabasePassword | Test-DlmDatabaseConnection
  36.  
  37. # Stop on any warnings
  38. $highWarnings = $databaseUpdate.Warnings | Where { $_.Severity -eq "High" }
  39. if($highWarnings.Count -gt 0)
  40. {
  41. [string]$highWarningsDetails = ""
  42. $highWarnings | ForEach-Object { $highWarningsDetails = $highWarningsDetails + $_.Details + "`n" }
  43. throw [System.Exception] $highWarningsDetails
  44. }
  45.  
  46. # Update target from database release object
  47. Import-DlmDatabaseRelease $DatabaseDeploymentResourcesPath | Use-DlmDatabaseRelease -DeployTo $targetDb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement