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

@@ -172,13 +172,19 @@ class UpdateRepository
foreach ( $manifest['sql'] as $query ) {
$query = trim( $query );
if ( $query !== '' ) {
if ( $query === '' || strpos( $query, '--' ) === 0 ) {
continue;
}
try {
if ( $this->db->query( $query ) ) {
$success++;
} else {
$errors++;
$log[] = '[WARNING] Błąd SQL: ' . $query;
}
} catch ( \Exception $e ) {
$errors++;
$log[] = '[WARNING] Wyjątek SQL: ' . $e->getMessage() . ' | Query: ' . substr( $query, 0, 200 );
}
}