mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 10:04:41 +00:00
mvc - extend model implementation to ease legacy migrations.
add migration strategy for LegacyMappers, when data is already available, migration should add uuid's to the records. Missed this in 35b5e0b64b
This commit is contained in:
parent
084abdfb45
commit
e516ea7ec8
@ -85,6 +85,12 @@ abstract class BaseModel
|
||||
*/
|
||||
private static $internalCacheReflectionClasses = null;
|
||||
|
||||
/**
|
||||
* uuid missing on load
|
||||
* @var bool
|
||||
*/
|
||||
private $internalMissingUuids = false;
|
||||
|
||||
/**
|
||||
* If the model needs a custom initializer, override this init() method
|
||||
* Default behaviour is to do nothing in this init.
|
||||
@ -253,6 +259,7 @@ abstract class BaseModel
|
||||
$tagUUID = (string)$conf_section->attributes()['uuid'];
|
||||
} else {
|
||||
$tagUUID = $internal_data->generateUUID();
|
||||
$this->internalMissingUuids = true;
|
||||
}
|
||||
|
||||
// iterate array items from config data
|
||||
@ -699,6 +706,10 @@ abstract class BaseModel
|
||||
public function runMigrations()
|
||||
{
|
||||
if ($this->isVolatile() || $this->isLegacyMapper()) {
|
||||
if ($this->isLegacyMapper() && $this->internalMissingUuids) {
|
||||
$this->serializeToConfig();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} elseif (version_compare($this->internal_current_model_version ?? '0.0.0', $this->internal_model_version, '<')) {
|
||||
$upgradePerformed = false;
|
||||
|
||||
@ -63,6 +63,10 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
|
||||
echo "*** " . $mdl_class_info->getName() . " Migration failed, check log for details\n";
|
||||
}
|
||||
} elseif (!empty($version_post)) {
|
||||
if ($mig_performed) {
|
||||
echo "Migrated " . $mdl_class_info->getName() . "\n";
|
||||
$executed_migration = true;
|
||||
}
|
||||
/* only relevant for debugging: */
|
||||
//echo "Keep version " . $mdl_class_info->getName() . " (" . $version_post . ")\n";
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user