数据库升级版本优化

This commit is contained in:
Weiming committed 2026-12-02 15:06:48 +08:00
1 parent f44594d213
commit debea9bb36
49 files changed
+5937 -714

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
param(
[Parameter(Mandatory = $true)][string]$JdbcUrl,
[Parameter(Mandatory = $true)][string]$User,
[Parameter(Mandatory = $true)][string]$SnapshotDirectory,
[string]$PlanPath = (Join-Path $SnapshotDirectory "V19_RECOVERY_PLAN.tsv"),
[string]$ExpectedPlanHash,
[string]$PasswordEnv = "DB_PASSWORD",
[ValidateRange(0, 3600)][int]$LockTimeoutSeconds = 60,
[switch]$Apply
)
$ErrorActionPreference = "Stop"
$backend = (Resolve-Path (Join-Path $PSScriptRoot "..\..\financial_system_backend")).Path
$snapshot = (Resolve-Path $SnapshotDirectory).Path
$v19Script = (Resolve-Path (Join-Path $PSScriptRoot "..\migrations\mysql\V20261009_19__menu_tree_derived_authorization.sql")).Path
$plan = [System.IO.Path]::GetFullPath($PlanPath)
$classpathFile = Join-Path $backend "target\migration-classpath.txt"
$mode = if ($Apply) { "apply" } else { "validate" }
if ($Apply -and [string]::IsNullOrWhiteSpace($ExpectedPlanHash)) {
throw "V19_RECOVERY_EXPECTED_PLAN_REQUIRED"
}
if (-not $Apply -and -not [string]::IsNullOrWhiteSpace($ExpectedPlanHash)) {
throw "V19_RECOVERY_EXPECTED_PLAN_NOT_ALLOWED"
}
Push-Location $backend
try {
& mvn.cmd -q -DskipTests compile dependency:build-classpath "-Dmdep.outputFile=$classpathFile"
if ($LASTEXITCODE -ne 0) { throw "V19_RECOVERY_BUILD_FAILED" }
$dependencyClasspath = Get-Content -Raw $classpathFile
$classpath = (Join-Path $backend "target\classes") + ";" + $dependencyClasspath.Trim()
$arguments = @(
"-cp", $classpath,
"com.finance.system.migration.V19RolePermissionRecovery",
"--url=$JdbcUrl", "--user=$User", "--password-env=$PasswordEnv",
"--snapshot=$snapshot", "--v19-script=$v19Script", "--plan=$plan",
"--mode=$mode", "--lock-timeout-seconds=$LockTimeoutSeconds"
)
if ($Apply) { $arguments += "--expected-plan-hash=$ExpectedPlanHash" }
& java @arguments
if ($LASTEXITCODE -ne 0) { throw "V19_RECOVERY_FAILED" }
} finally {
Pop-Location
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.