- Bugfixes and work done on the console
This commit is contained in:
1 parent
23af120020
commit
7194a33bec
6 files changed
+71
-15
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Console\Controller;
|
||||
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
|
||||
use Notes\Route\Annotation\Object\Route as RouteParam,
|
||||
Notes\Route\Annotation\Method\Route,
|
||||
Notes\Security\Annotation\Security,
|
||||
Notes\Tell\Annotation\Language;
|
||||
|
||||
use \Lean\Console\Lib;
|
||||
|
||||
/**
|
||||
* @Language("lean.dev")
|
||||
*/
|
||||
class Dev {
|
||||
use Lib\ConsoleControllerTrait;
|
||||
|
||||
/**
|
||||
* @Route("/phpinfo", "name" => "lean.dev:phpinfo")
|
||||
*/
|
||||
public function home(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
||||
{
|
||||
phpinfo();
|
||||
die();
|
||||
}
|
||||
}
|
||||
+26
-9
@@ -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);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ use Picea;
|
||||
/**
|
||||
* @Language("lean.route")
|
||||
* @RouteParam("methods" => [ 'GET', 'POST', 'DELETE' ], "base" => "/~")
|
||||
* @Security('locked' => false)
|
||||
* @Security('locked' => true)
|
||||
* @Taxus("admin")
|
||||
*/
|
||||
trait ConsoleControllerTrait
|
||||
{
|
||||
@@ -23,6 +24,5 @@ trait ConsoleControllerTrait
|
||||
$this->picea = $picea;
|
||||
$this->session = $session;
|
||||
$this->container = $container;
|
||||
// $this->mailer = $mailer;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ class DatabaseMigrations
|
||||
$this->entities[$entity] = $entity::resolveEntity();
|
||||
}
|
||||
}
|
||||
|
||||
ksort($this->entities);
|
||||
}
|
||||
|
||||
protected static function files(string $path, string $fileExtension = "") : \Generator
|
||||
|
||||
Reference in new issue
Block a user