ps/Modules/Alkami.PowerShell.Database/Public/Invoke-AlkamiLegacyOrbMigrations.ps1

121 lines
4.7 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function Invoke-AlkamiLegacyOrbMigrations {
<#
.SYNOPSIS
Run migrations against ORB tenant, master, etc databases by calling Invoke-AlkamiMigrationRunner
.DESCRIPTION
Used to call the Alkami MigrationUtility for running migrations against various systems
.PARAMETER ConnectionString
The connection string of the AlkamiMaster database to run migrations against.
.PARAMETER OrbMigrateFolderPath
The location where ORB migration dlls are located. This is typically supplied as part of the deployment process.
.PARAMETER Parallelism
This value determines how many threads/workers are used in parallel to the service.
Values should be supplied higher than 0. A value of -1 indicates to run as many threads as possible.
.PARAMETER LogFileFolder
When supplied, the output of the migration runner will be redirected to the specified path.
If the folder does not exist, it will be created.
If the file already exists, it will be overwritten.
If the PackageId and PackageVersion are provided, the results will be directed to a file with the name format of "{package id}.{version}.log" in the specified folder.
Otherwise the log file will be written to a file named after the MigrationTypeName value with the Process.ID appended like so "{migration type name}.{process id}.log"
NOTE: This parameter should not be used in a TeamCity process as it will not emit anything to the TeamCity process.
.PARAMETER WhatIf
Supply this parameter to see what would happen if the utility were to run to completion.
.PARAMETER Tags
Supply this parameter to FluentMigrations for ex: SDK
.PARAMETER LogTeamCityMessages
Required to log team city control messages at all
Omitting the LogTeamCityMessages flag will not cause messages to be ommitted, for that you should set the global logging to NONE, but will instead omit the use of TeamCity Service Messages, such as ##teamcity(message
.PARAMETER NoTeamCityBlockMessages
Will prevent OpenBlock and CloseBlock messages from happening
.PARAMETER NoTeamCityBuildProblems
Will prevent BuildProblems from emitting as a build problem
.PARAMETER NoTeamCityMessages
Will prevent Messages from being written (you should probably just not /LogTeamCityMessages if you get to this point)
.PARAMETER LogErrorsAsWarn
Will not use the ERROR message format, all will goto WARN, this is to prevent certain TC job steps from stopping the pipeline
.OUTPUTS
This cmdlet does not return anything directly, but there will be a $EXITCODE value set,
and this process will emit TeamCity BuildError and Message when run on TeamCity servers.
On any other environment, logs will be emitted to the console (standard output) and may be captured
.LINK
Get-MigrationRunnerExe
#>
[CmdletBinding()]
[OutputType([void])]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "Use of WhatIf flag intentional so we track the presence of it")]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$ConnectionString,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$OrbMigrateFolderPath,
# Has a default value in the app already, no need to configure it unless desired
[Parameter(Mandatory = $false)]
[int]$Parallelism,
[Parameter(Mandatory = $false)]
[string]$LogFileFolder,
[Parameter(Mandatory = $false)]
[switch]$WhatIf,
[Parameter(Mandatory = $false)]
[string[]]$Tags,
[Parameter(Mandatory = $false)]
[Alias('EnableTeamCityServiceMessages')]
[switch]$LogTeamCityMessages,
[Parameter(Mandatory = $false)]
[Alias("PreventTeamCityBlocks")]
[switch]$NoTeamCityBlockMessages,
[Parameter(Mandatory = $false)]
[Alias("PreventTeamCityBuildProblems")]
[switch]$NoTeamCityBuildProblems,
[Parameter(Mandatory = $false)]
[Alias("PreventTeamCityMessages")]
[switch]$NoTeamCityMessages,
[Parameter(Mandatory = $false)]
[Alias("LogTeamCityErrorMessagesAsWarn")]
[switch]$LogErrorsAsWarn
)
$migrationSplat = @{
ConnectionString = $ConnectionString
MigrationTypeName = "orb"
OrbMigrateFolderPath = $OrbMigrateFolderPath
WhatIf = $WhatIf
LogFileFolder = $LogFileFolder
Parallelism = $Parallelism
LogTeamCityMessages = $LogTeamCityMessages
NoTeamCityBlockMessages = $NoTeamCityBlockMessages
NoTeamCityBuildProblems = $NoTeamCityBuildProblems
NoTeamCityMessages = $NoTeamCityMessages
LogErrorsAsWarn = $LogErrorsAsWarn
}
Invoke-AlkamiMigrationRunner @migrationSplat
}