- Bugfixes and work done on the console

This commit is contained in:
Dave Mc Nicoll committed 2021-08-27 18:06:55 +00:00
1 parent 23af120020
commit 7194a33bec
6 files changed
+71 -15

No files matched your search

+26 -9
View File
@@ -8,6 +8,7 @@ use \Lean\Console\Lib;
use Picea\Compiler\Context;
use Psr\Http\Message\ServerRequestInterface;
use Ulmus\Common\EntityResolver;
use \Ulmus\Entity\InformationSchema\Table;
class Database implements FormInterface
@@ -31,22 +32,35 @@ class Database implements FormInterface
continue;
}
$table = Table::repository()->where(Table::field('name'), $table->tableName())
$table = Table::repository()
->where(Table::field('name'), $table->tableName())
->where(Table::field('schema'), $table->databaseName())
->loadOne();
if ( $table ) {
#$fields = $entiy::resolveEntity()->fieldList();
$fields = $entity::resolveEntity()->fieldList(EntityResolver::KEY_COLUMN_NAME, true);
foreach($table->columns as $col) {
//dump( $entity::field($col->name) );
$alter = [];
foreach($fields as $field => $definition) {
if ( $table->columns->filtersCollection(fn($e) => $e->name === $field)->count() === 0 ) {
$alter[$field] = $definition;
}
}
# if columns are different
$context->status[$entity] = [
'msg' => "up-to-date",
'query' => "",
];
if ( $alter ) {
$context->status[$entity] = [
'msg' => "alter",
"query" => $entity::repository()->alterSqlQuery($alter)->getSqlQuery(true),
];
}
else {
# if columns are different
$context->status[$entity] = [
'msg' => "up-to-date",
'query' => "",
];
}
}
else {
$context->status[$entity] = [
@@ -76,6 +90,9 @@ class Database implements FormInterface
$entity::repository()->createTable();
}
}
elseif ( $context->alter ?? false ) {
}
$this->initialize($context);
}