run_wx_sop_tenant_upgrade.ps1 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Run Wx SOP TenantUpgrade on test tenant (JDBC, same SQL as TenantUpgradeService)
  2. # Usage:
  3. # cd d:\ylrz_saas_new\java\scripts
  4. # .\run_wx_sop_tenant_upgrade.ps1
  5. # .\run_wx_sop_tenant_upgrade.ps1 -TenantDb ylrz_saas_tenant_1 -ToVersion V20260614_04
  6. param(
  7. [string]$TenantDb = "ylrz_saas_tenant_1",
  8. [long]$TenantId = 32,
  9. [string]$FromVersion = "",
  10. [string]$ToVersion = "V20260614_04",
  11. [string]$ApiBase = "http://127.0.0.1:8004",
  12. [switch]$UseApi
  13. )
  14. $ErrorActionPreference = "Stop"
  15. $scriptDir = $PSScriptRoot
  16. $javaHome = if ($env:JAVA_HOME) { $env:JAVA_HOME } else { "D:\AICALL\jdk-17.0.12+7" }
  17. $java = Join-Path $javaHome "bin\java.exe"
  18. Write-Host "=== Wx SOP TenantUpgrade ===" -ForegroundColor Cyan
  19. Write-Host "TenantId=$TenantId TenantDb=$TenantDb ToVersion=$ToVersion"
  20. if ($UseApi) {
  21. Write-Host "API mode not fully automated (captcha). Use JDBC mode." -ForegroundColor Yellow
  22. }
  23. Push-Location (Join-Path $scriptDir "..")
  24. try {
  25. $cpFile = Join-Path $scriptDir "tenant_upgrade_cp.txt"
  26. & mvn -q -pl fs-saas-admin dependency:build-classpath "-Dmdep.outputFile=$cpFile" 2>&1 | Out-Null
  27. if (-not (Test-Path $cpFile)) { throw "Failed to build classpath" }
  28. $cp = Get-Content $cpFile -Raw
  29. $src = Join-Path $scriptDir "RunTenantUpgrade.java"
  30. $outDir = Join-Path $scriptDir "out"
  31. New-Item -ItemType Directory -Force -Path $outDir | Out-Null
  32. & javac -encoding UTF-8 -cp $cp -d $outDir $src
  33. if ($LASTEXITCODE -ne 0) { throw "javac failed" }
  34. $fromArg = if ([string]::IsNullOrWhiteSpace($FromVersion)) { '""' } else { $FromVersion }
  35. & $java -cp "$outDir;$cp" RunTenantUpgrade $TenantDb $fromArg $ToVersion
  36. if ($LASTEXITCODE -ne 0) { throw "RunTenantUpgrade failed exit=$LASTEXITCODE" }
  37. } finally {
  38. Pop-Location
  39. }
  40. Write-Host ""
  41. Write-Host "Done. Re-login saas-adminui (test001) to refresh menus." -ForegroundColor Green