- 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 Psr\Http\Message\ServerRequestInterface;
|
||||||
use Ulmus\Common\EntityResolver;
|
use Ulmus\Common\EntityResolver;
|
||||||
use \Ulmus\Entity\InformationSchema\Table;
|
use \Ulmus\Entity\InformationSchema\Table;
|
||||||
|
use Ulmus\Ulmus;
|
||||||
|
|
||||||
class Migrate implements FormInterface
|
class Migrate implements FormInterface
|
||||||
{
|
{
|
||||||
@ -47,6 +48,11 @@ class Migrate implements FormInterface
|
|||||||
$this->definition[$entity]['columns'] = new Lib\Database\DefinitionCollection();
|
$this->definition[$entity]['columns'] = new Lib\Database\DefinitionCollection();
|
||||||
|
|
||||||
foreach($table->fieldList(EntityResolver::KEY_COLUMN_NAME, true) as $field => $definition) {
|
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(
|
$this->definition[$entity]['columns'][$field] = $def = new Lib\Database\Definition(
|
||||||
entity: $entity,
|
entity: $entity,
|
||||||
field: $field,
|
field: $field,
|
||||||
@ -60,17 +66,12 @@ class Migrate implements FormInterface
|
|||||||
# Column do not exists
|
# Column do not exists
|
||||||
if ( $column === null ) {
|
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) ) {
|
elseif ( ! $column->matchFieldDefinition($definition) ) {
|
||||||
$def->action = "change";
|
$def->action = "change";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($def->action) {
|
||||||
$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()
|
||||||
@ -80,7 +81,6 @@ class Migrate 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() ) {
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
{% section "content" %}
|
{% section "content" %}
|
||||||
|
|
||||||
{% if $connections %}
|
{% if $connections %}
|
||||||
{% foreach $connections as $connection %}
|
{% foreach $connections as $connection %}
|
||||||
<section>
|
<section>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user