- WIP on Lean console definition change

This commit is contained in:
Dave Mc Nicoll 2024-08-30 19:01:21 +00:00
parent d76148fed9
commit ac568b1750
1 changed files with 14 additions and 1 deletions

View File

@ -55,10 +55,22 @@ class DatabaseMigration implements FormInterface
previous: $def ?? null,
);
$column = $tableEntity->columns->filtersOne(fn($e) => strtolower($e->name) === $field);
# Column do not exists
if ( $tableEntity->columns->filtersCollection(fn($e) => strtolower($e->name) === $field)->count() === 0 ) {
if ( $column === null ) {
$def->action = "add";
$def->modifier = new Lib\Database\Modifier(
type: Lib\Database\ModifierTypeEnum::Alter,
query: $entity::repository()
->alterSqlQuery([ $def->toArray() ])
->getSqlQuery(true)
);
}
elseif ( ! $column->matchFieldDefinition($definition) ) {
$def->action = "change";
$def->modifier = new Lib\Database\Modifier(
type: Lib\Database\ModifierTypeEnum::Alter,
query: $entity::repository()
@ -68,6 +80,7 @@ class DatabaseMigration implements FormInterface
}
}
# ALTER TABLE `ajustements` CHANGE `annee` `annee` INT(11) NULL;
$alter = $this->definition[$entity]['columns']->filterAlter();
if ( $alter->count() ) {