Update db exception handling in installer

DB object returns errors on warnings, so was failing.

Ignore the warnings and only die on exceptions (usually violations) as it is normal that there are warnings if we are changing VARCHAR to ENUM
This commit is contained in:
steve-lad 2021-06-27 11:42:21 +02:00
parent 4fcf16b317
commit b1a7fe3510
No known key found for this signature in database
GPG key ID: 4D1D760BACDAFF81

View file

@ -465,9 +465,10 @@ function InstallDB_updateSchema($db_config)
if (!empty($sql_create)) { if (!empty($sql_create)) {
outn("<li>" . _("Adding new FILTER_VALIDATE_INT") . "</li>"); outn("<li>" . _("Adding new FILTER_VALIDATE_INT") . "</li>");
$sql_create = "ALTER TABLE {$tabl_name} " .substr($sql_create, 0, -2); $sql_create = "ALTER TABLE {$tabl_name} " .substr($sql_create, 0, -2);
try {
$check = $db->query($sql_create); $check = $db->query($sql_create);
if (DB::IsError($check)) { } catch (\Exception $e) {
die_freepbx("Can not create {$tabl_name}. SQL: {$sql_create} \n"); die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_create} \n");
} }
} }
if (!empty($sql_modify)) { if (!empty($sql_modify)) {
@ -477,7 +478,6 @@ function InstallDB_updateSchema($db_config)
try { try {
$check = $db->query($sql_modify); $check = $db->query($sql_modify);
} catch (\Exception $e) { } catch (\Exception $e) {
dbug('exception is', $e);
die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_create} \n"); die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_create} \n");
} }
} }