mvc - change exception handling in runMigrations() to avoid mismatches in attributes being silently ignored.

When a migration tries to address an non existing attribute, a InvalidArgumentException is thrown, but only partially noted in the log.
It's likely safer to abort the migration if steps fail and send the error to the log for further inspection.
This commit is contained in:
Ad Schellevis 2024-03-25 21:12:46 +01:00
parent e23fee9ec7
commit 14ea1b96e8

View File

@ -721,7 +721,7 @@ abstract class BaseModel
$class_info = new ReflectionClass($this);
// fetch version migrations
$versions = array();
$versions = [];
// set default migration for current model version
$versions[$this->internal_model_version] = __DIR__ . "/BaseModelMigration.php";
$migprefix = $this->internal_model_migration_prefix;
@ -757,7 +757,10 @@ abstract class BaseModel
} catch (Exception $e) {
$logger->error("failed migrating from version " .
$this->getVersion() . " to " . $mig_version . " in " .
$class_info->getName() . " [skipping step]");
$class_info->getName() . " ( " . $e . " )");
/* fail migration when exceptions are thrown */
$this->internal_current_model_version = $mig_version;
return false;
}
$this->internal_current_model_version = $mig_version;
}