apply_lobster_execution_tenant32.ps1 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Apply lobster execution + template personalization SQL for tenant 32
  2. # Requires mysql client in PATH, or run SQL manually in DataGrip.
  3. #
  4. # Usage:
  5. # cd d:\ylrz_saas_new\java\scripts
  6. # .\apply_lobster_execution_tenant32.ps1
  7. # .\apply_lobster_execution_tenant32.ps1 -Host xxx -Port 27220 -User root -Password '***'
  8. param(
  9. [string]$Host = "cq-cdb-8fjmemkb.sql.tencentcdb.com",
  10. [int]$Port = 27220,
  11. [string]$User = "root",
  12. [string]$Password = $env:DB_PASSWORD,
  13. [string]$TenantDb = "ylrz_saas_tenant_1",
  14. [string]$MasterDb = "ylrz_saas"
  15. )
  16. $ErrorActionPreference = "Stop"
  17. $sqlFile = Join-Path $PSScriptRoot "..\sql\manual\lobster_execution_tenant32_deploy.sql"
  18. if (-not (Get-Command mysql -ErrorAction SilentlyContinue)) {
  19. Write-Host "mysql client not found. Run manually:" -ForegroundColor Yellow
  20. Write-Host " Tenant DB ($TenantDb): PART A in $sqlFile"
  21. Write-Host " Master DB ($MasterDb): PART B in $sqlFile"
  22. exit 1
  23. }
  24. if (-not $Password) {
  25. Write-Host "Set DB password: `$env:DB_PASSWORD='your_password'" -ForegroundColor Yellow
  26. exit 1
  27. }
  28. Write-Host "=== Apply PART A -> $TenantDb ===" -ForegroundColor Cyan
  29. $partA = (Get-Content $sqlFile -Raw) -split '-- ===================== PART B' | Select-Object -First 1
  30. $partA = ($partA -split '-- ===================== PART A')[1]
  31. $partA | mysql -h $Host -P $Port -u $User "-p$Password" $TenantDb
  32. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  33. Write-Host "=== Apply PART B -> $MasterDb ===" -ForegroundColor Cyan
  34. $partB = '-- ===================== PART B' + (($sqlFile | Get-Content -Raw) -split '-- ===================== PART B')[1]
  35. $partB | mysql -h $Host -P $Port -u $User "-p$Password" $MasterDb
  36. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  37. Write-Host "=== Done. Restart fs-saas-company / fs-saas-admin ===" -ForegroundColor Green