Skip to content

Instantly share code, notes, and snippets.

@Alex-Yates
Created July 13, 2016 16:33
Show Gist options
  • Save Alex-Yates/dbe0e8bd937230e038495c6f51a8fb63 to your computer and use it in GitHub Desktop.
Save Alex-Yates/dbe0e8bd937230e038495c6f51a8fb63 to your computer and use it in GitHub Desktop.
Write-Output "***************************"
Write-Output "***** DEPLOY DATABASE *****"
Write-Output "***************************"
# Configuration
$pipeline = ${env:PIPELINE_NUMBER}.trim()
$schemaComparePath = 'C:\\Program Files\\Red Gate\\Schema Compare for Oracle 3\\SCO.exe'
$targetSchemaName = "MySchema_INTEGRATION"
$schemaRelativePath = ""
$tns = "MyTNS"
$username = "MyUsername"
$password = "YourReallyWantToPerameteriseAndEncryptThis-ButForThePoCIllLetYouOff"
$sourceName = "MySchema"
$extractedNuGetDirectory = "${env:Workspace}\ExtractedNuGet\${schemaRelativePath}{$sourceName}"
$deploymentArtifactDirectory = "${env:Workspace}\artifacts\${pipeline}"
# Logging config variables for troubleshooting
Write-Output "Using the following variables:"
Write-Output "pipeline: $pipeline"
Write-Output "schemaComparePath: $schemaComparePath"
Write-Output "schemaRelativePath: $schemaRelativePath"
Write-Output "targetSchemaName: $targetSchemaName"
Write-Output "tns: $tns"
Write-Output "username: $username"
Write-Output "password: $password"
Write-Output "sourceName: $sourceName"
Write-Output "extractedNuGetDirectory: $extractedNuGetDirectory"
Write-Output "deploymentArtifactDirectory: $deploymentArtifactDirectory "
# Deploy changes using Redgate Schema Compare for Oracle
Write-Warning "Upgrading $targetSchemaName"
& $schemaComparePath -source $extractedNuGetDirectory -target "$username/$password@$tns{$targetSchemaName}" -deploy -scriptfile "${deploymentArtifactDirectory}\upgradeScript.sql" -report "${deploymentArtifactDirectory}\diffReport.html" -reporttype Simple -includeidentical | Out-Host
# Logging the Schema Compare exit code and path to artifacts
Write-Output "Schema Compare for Oracle exited with code $lastExitCode"
Write-Output "UpgradeScript and diff report created and saved to ${deploymentArtifactDirectory}"
# Exit code 61 is simply telling us there are differences that have been deployed.
if( $lastExitCode -eq 61)
{
exit 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment