Kansho/scripts/sqlite-to-postgres.ps1

30 lines
803 B
PowerShell
Raw Normal View History

# Wrapper for backend/sqlite_to_postgres.py (personal data, require -Confirm).
[CmdletBinding()]
param(
[string]$Sqlite,
[string]$MediaSrc,
[string]$MediaDest,
[switch]$Confirm,
[switch]$Replace
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$root = Split-Path -Parent $PSScriptRoot
$py = Join-Path $root "backend\.venv\Scripts\python.exe"
if (-not (Test-Path $py)) {
$py = "python"
}
$env:PYTHONUTF8 = "1"
$argsList = @((Join-Path $root "backend\sqlite_to_postgres.py"))
if ($Sqlite) { $argsList += @("--sqlite", $Sqlite) }
if ($MediaSrc) { $argsList += @("--media-src", $MediaSrc) }
if ($MediaDest) { $argsList += @("--media-dest", $MediaDest) }
if ($Confirm) { $argsList += "--confirm" }
if ($Replace) { $argsList += "--replace" }
& $py @argsList
exit $LASTEXITCODE