Add ROA uninstall/cleanup script for testing iterations
- sql/uninstall-roa.sql: Removes all ROA objects in correct order - Drops company users (dynamically detected by ROA tablespace) - Drops CONTAFIN_ORACLE user CASCADE - Drops public synonyms pointing to CONTAFIN_ORACLE - Drops SYS custom objects (AUTH_PACK, AUTH_SERII, INFO, etc.) - Drops application context SESIUNE - Drops tablespace ROA including datafiles - scripts/99-uninstall-roa.ps1: PowerShell wrapper with confirmation - Updated README with uninstall documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
# ============================================================================
|
||||
# ROA UNINSTALL SCRIPT
|
||||
# ============================================================================
|
||||
# Removes all ROA application objects from Oracle database
|
||||
#
|
||||
# Usage:
|
||||
# .\99-uninstall-roa.ps1 -SystemPassword "yourpassword"
|
||||
# .\99-uninstall-roa.ps1 -SystemPassword "yourpassword" -Force
|
||||
#
|
||||
# Parameters:
|
||||
# -SystemPassword : SYS password for database connection
|
||||
# -Force : Skip confirmation prompt
|
||||
#
|
||||
# ============================================================================
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$SystemPassword,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# ============================================================================
|
||||
# LOAD CONFIGURATION AND LIBRARIES
|
||||
# ============================================================================
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$RootDir = Split-Path -Parent $ScriptDir
|
||||
|
||||
# Load config
|
||||
$ConfigFile = Join-Path $RootDir "config.ps1"
|
||||
if (Test-Path $ConfigFile) {
|
||||
. $ConfigFile
|
||||
} else {
|
||||
Write-Host "ERROR: config.ps1 not found. Copy config.example.ps1 to config.ps1" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Load libraries
|
||||
. (Join-Path $ScriptDir "lib\logging-functions.ps1")
|
||||
. (Join-Path $ScriptDir "lib\oracle-functions.ps1")
|
||||
|
||||
# ============================================================================
|
||||
# MAIN
|
||||
# ============================================================================
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "============================================================" -ForegroundColor Cyan
|
||||
Write-Host " ROA UNINSTALL - REMOVING ALL ROA OBJECTS" -ForegroundColor Cyan
|
||||
Write-Host "============================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Get password if not provided
|
||||
if (-not $SystemPassword) {
|
||||
$SecurePassword = Read-Host "Enter SYS password" -AsSecureString
|
||||
$SystemPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
|
||||
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)
|
||||
)
|
||||
}
|
||||
|
||||
# Build connection string
|
||||
$OracleService = if ($Config.OracleService) { $Config.OracleService } else { "XEPDB1" }
|
||||
$OracleHost = if ($Config.OracleHost) { $Config.OracleHost } else { "localhost" }
|
||||
$OraclePort = if ($Config.OraclePort) { $Config.OraclePort } else { 1521 }
|
||||
$ConnString = "${OracleHost}:${OraclePort}/${OracleService}"
|
||||
|
||||
Write-Host "Target database: $ConnString" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# Confirmation
|
||||
if (-not $Force) {
|
||||
Write-Host "WARNING: This will PERMANENTLY DELETE all ROA data!" -ForegroundColor Red
|
||||
Write-Host ""
|
||||
Write-Host "Objects to be removed:" -ForegroundColor Yellow
|
||||
Write-Host " - All company user schemas (using ROA tablespace)"
|
||||
Write-Host " - CONTAFIN_ORACLE user and all objects"
|
||||
Write-Host " - Public synonyms pointing to CONTAFIN_ORACLE"
|
||||
Write-Host " - SYS custom objects (AUTH_PACK, AUTH_SERII, etc.)"
|
||||
Write-Host " - Application context SESIUNE"
|
||||
Write-Host " - Tablespace ROA (including datafile)"
|
||||
Write-Host ""
|
||||
|
||||
$confirm = Read-Host "Type 'YES' to confirm uninstall"
|
||||
if ($confirm -ne "YES") {
|
||||
Write-Host "Uninstall cancelled." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Starting uninstall..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Find sqlplus
|
||||
$SqlPlus = Get-SqlPlusPath
|
||||
if (-not $SqlPlus) {
|
||||
Write-Host "ERROR: sqlplus.exe not found" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Run uninstall script
|
||||
$SqlScript = Join-Path $RootDir "sql\uninstall-roa.sql"
|
||||
|
||||
if (-not (Test-Path $SqlScript)) {
|
||||
Write-Host "ERROR: uninstall-roa.sql not found at $SqlScript" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Running uninstall script..." -ForegroundColor Cyan
|
||||
|
||||
$SqlInput = @"
|
||||
@"$SqlScript"
|
||||
EXIT
|
||||
"@
|
||||
|
||||
$process = Start-Process -FilePath $SqlPlus `
|
||||
-ArgumentList "sys/${SystemPassword}@${ConnString} as sysdba" `
|
||||
-NoNewWindow -Wait -PassThru `
|
||||
-RedirectStandardInput (New-TemporaryFile | ForEach-Object {
|
||||
$SqlInput | Set-Content $_.FullName
|
||||
$_.FullName
|
||||
})
|
||||
|
||||
# Alternative: run directly
|
||||
& $SqlPlus "sys/${SystemPassword}@${ConnString} as sysdba" "@$SqlScript"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "============================================================" -ForegroundColor Green
|
||||
Write-Host " ROA UNINSTALL COMPLETE" -ForegroundColor Green
|
||||
Write-Host "============================================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Database is now clean. You can re-run the setup scripts." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user