- WIP on Mssql migrations
This commit is contained in:
parent
d8b208426a
commit
5b68bb191b
@ -10,6 +10,7 @@ use Picea\Compiler\Context;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\Common\EntityResolver;
|
||||
use \Ulmus\Entity\InformationSchema\Table;
|
||||
use Ulmus\Ulmus;
|
||||
|
||||
class Migrate implements FormInterface
|
||||
{
|
||||
@ -47,6 +48,11 @@ class Migrate implements FormInterface
|
||||
$this->definition[$entity]['columns'] = new Lib\Database\DefinitionCollection();
|
||||
|
||||
foreach($table->fieldList(EntityResolver::KEY_COLUMN_NAME, true) as $field => $definition) {
|
||||
|
||||
if ( isset($definition->value) ) {
|
||||
$definition->value = $entity::repository()->adapter->adapter()->writableValue($definition->value);
|
||||
}
|
||||
|
||||
$this->definition[$entity]['columns'][$field] = $def = new Lib\Database\Definition(
|
||||
entity: $entity,
|
||||
field: $field,
|
||||
@ -60,17 +66,12 @@ class Migrate implements FormInterface
|
||||
# Column do not exists
|
||||
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";
|
||||
}
|
||||
|
||||
if ($def->action) {
|
||||
$def->modifier = new Lib\Database\Modifier(
|
||||
type: Lib\Database\ModifierTypeEnum::Alter,
|
||||
query: $entity::repository()
|
||||
@ -80,7 +81,6 @@ class Migrate implements FormInterface
|
||||
}
|
||||
}
|
||||
|
||||
# ALTER TABLE `ajustements` CHANGE `annee` `annee` INT(11) NULL;
|
||||
$alter = $this->definition[$entity]['columns']->filterAlter();
|
||||
|
||||
if ( $alter->count() ) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
{% endsection %}
|
||||
|
||||
{% section "content" %}
|
||||
|
||||
{% if $connections %}
|
||||
{% foreach $connections as $connection %}
|
||||
<section>
|
||||
|
Loading…
x
Reference in New Issue
Block a user