- WIP on Lean console definition change
This commit is contained in:
parent
d76148fed9
commit
ac568b1750
|
@ -55,10 +55,22 @@ class DatabaseMigration implements FormInterface
|
||||||
previous: $def ?? null,
|
previous: $def ?? null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$column = $tableEntity->columns->filtersOne(fn($e) => strtolower($e->name) === $field);
|
||||||
|
|
||||||
# Column do not exists
|
# Column do not exists
|
||||||
if ( $tableEntity->columns->filtersCollection(fn($e) => strtolower($e->name) === $field)->count() === 0 ) {
|
if ( $column === null ) {
|
||||||
$def->action = "add";
|
$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(
|
$def->modifier = new Lib\Database\Modifier(
|
||||||
type: Lib\Database\ModifierTypeEnum::Alter,
|
type: Lib\Database\ModifierTypeEnum::Alter,
|
||||||
query: $entity::repository()
|
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();
|
$alter = $this->definition[$entity]['columns']->filterAlter();
|
||||||
|
|
||||||
if ( $alter->count() ) {
|
if ( $alter->count() ) {
|
||||||
|
|
Loading…
Reference in New Issue