fix: broken SQL in update manifests — line-by-line instead of complete statements

build-update.ps1 was reading SQL migrations line-by-line, causing
multi-line CREATE TABLE/INSERT statements to be stored as fragments
in manifests. Fixed to strip comments, join lines, and split by
semicolons. Fixed ver_0.324_manifest.json with correct SQL statements.
Added try-catch in UpdateRepository to prevent fatal crashes on SQL errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 14:48:08 +01:00
parent 98029b1720
commit 28f53b7998
3 changed files with 14 additions and 47 deletions

View File

@@ -215,7 +215,10 @@ $sqlQueries = @()
$migrationFile = "migrations/$versionNumber.sql"
if (Test-Path $migrationFile) {
$sqlQueries = @(Get-Content $migrationFile | Where-Object { $_.Trim() -ne '' } | ForEach-Object { $_.ToString() })
# Read entire file, strip comment lines, split by semicolons to get complete SQL statements
$rawLines = Get-Content $migrationFile | Where-Object { $_.Trim() -ne '' -and $_.Trim() -notmatch '^\s*--' }
$rawSql = ($rawLines -join "`n").Trim()
$sqlQueries = @($rawSql -split ';' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' } | ForEach-Object { $_.ToString() })
Write-Step "Znaleziono migracje SQL: $migrationFile ($($sqlQueries.Count) zapytan)"
} else {
Write-Step "Brak migracji SQL ($migrationFile nie istnieje)"