| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # Apply lobster execution + template personalization SQL for tenant 32
- # Requires mysql client in PATH, or run SQL manually in DataGrip.
- #
- # Usage:
- # cd d:\ylrz_saas_new\java\scripts
- # .\apply_lobster_execution_tenant32.ps1
- # .\apply_lobster_execution_tenant32.ps1 -Host xxx -Port 27220 -User root -Password '***'
- param(
- [string]$Host = "cq-cdb-8fjmemkb.sql.tencentcdb.com",
- [int]$Port = 27220,
- [string]$User = "root",
- [string]$Password = $env:DB_PASSWORD,
- [string]$TenantDb = "ylrz_saas_tenant_1",
- [string]$MasterDb = "ylrz_saas"
- )
- $ErrorActionPreference = "Stop"
- $sqlFile = Join-Path $PSScriptRoot "..\sql\manual\lobster_execution_tenant32_deploy.sql"
- if (-not (Get-Command mysql -ErrorAction SilentlyContinue)) {
- Write-Host "mysql client not found. Run manually:" -ForegroundColor Yellow
- Write-Host " Tenant DB ($TenantDb): PART A in $sqlFile"
- Write-Host " Master DB ($MasterDb): PART B in $sqlFile"
- exit 1
- }
- if (-not $Password) {
- Write-Host "Set DB password: `$env:DB_PASSWORD='your_password'" -ForegroundColor Yellow
- exit 1
- }
- Write-Host "=== Apply PART A -> $TenantDb ===" -ForegroundColor Cyan
- $partA = (Get-Content $sqlFile -Raw) -split '-- ===================== PART B' | Select-Object -First 1
- $partA = ($partA -split '-- ===================== PART A')[1]
- $partA | mysql -h $Host -P $Port -u $User "-p$Password" $TenantDb
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- Write-Host "=== Apply PART B -> $MasterDb ===" -ForegroundColor Cyan
- $partB = '-- ===================== PART B' + (($sqlFile | Get-Content -Raw) -split '-- ===================== PART B')[1]
- $partB | mysql -h $Host -P $Port -u $User "-p$Password" $MasterDb
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- Write-Host "=== Done. Restart fs-saas-company / fs-saas-admin ===" -ForegroundColor Green
|