modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-06-14 11:25:34 +04:00
parent f431ce248a
commit e9ab61b154
5 changed files with 38 additions and 25 deletions

View File

@ -43,6 +43,15 @@ abstract class UpdateMigrationsApp extends Application {
*/ */
const DATABASES = null; const DATABASES = null;
/** @var bool valeur par défaut de $doSql si aucun argument n'est spécifié */
const DO_SQL = true;
/** @var bool valeur par défaut de $doClass si aucun argument n'est spécifié */
const DO_CLASS = true;
/** @var bool valeur par défaut de $doDoc si aucun argument n'est spécifié */
const DO_DOC = true;
const MIGRATE_PARAMS_SCHEMA = [ const MIGRATE_PARAMS_SCHEMA = [
"basedir" => ["?string", null, "chemin absolu du projet"], "basedir" => ["?string", null, "chemin absolu du projet"],
"overwrite" => ["?bool", null, "faut-il regénérer les fichier?"], "overwrite" => ["?bool", null, "faut-il regénérer les fichier?"],
@ -51,12 +60,12 @@ abstract class UpdateMigrationsApp extends Application {
"do_sql" => ["bool", null, "faut-il générer les fichiers SQL"], "do_sql" => ["bool", null, "faut-il générer les fichiers SQL"],
"sql_dir" => ["?string", null, "cf database_schema"], "sql_dir" => ["?string", null, "cf database_schema"],
"sql_prefix" => ["bool", null, "cf database_schema"], "sql_prefix" => ["bool", null, "cf database_schema"],
"do_doc" => ["bool", null, "faut-il générer la documentation"],
"doc_dir" => ["?string", null, "cf database_schema"],
"do_class" => ["bool", null, "faut-il générer les classes DAO"],
"class_dir" => ["?string", null, "cf database_schema"], "class_dir" => ["?string", null, "cf database_schema"],
"class_package" => ["?string", null, "cf database_schema"], "class_package" => ["?string", null, "cf database_schema"],
"class_baserow" => ["?string", null, "cf database_schema"], "class_baserow" => ["?string", null, "cf database_schema"],
"do_doc" => ["bool", null, "faut-il générer la documentation"],
"doc_dir" => ["?string", null, "cf database_schema"],
"do_class" => ["bool", null, "faut-il générer les classes DAO"],
]; ];
protected abstract function migrate(array $params); protected abstract function migrate(array $params);
@ -77,12 +86,12 @@ abstract class UpdateMigrationsApp extends Application {
["-s", "--sql-only", "name" => "do_sql", "value" => true, ["-s", "--sql-only", "name" => "do_sql", "value" => true,
"help" => "ne faire que la génération des fichiers SQL", "help" => "ne faire que la génération des fichiers SQL",
], ],
["-d", "--doc-only", "name" => "do_doc", "value" => true,
"help" => "ne faire que la génération de la documentation",
],
["-c", "--class-only", "name" => "do_class", "value" => true, ["-c", "--class-only", "name" => "do_class", "value" => true,
"help" => "ne faire que la génération des fichiers DAO", "help" => "ne faire que la génération des fichiers DAO",
], ],
["-d", "--doc-only", "name" => "do_doc", "value" => true,
"help" => "ne faire que la génération de la documentation",
],
["group", ["group",
["-l", "--select", "arg" => "value", "name" => "select", ["-l", "--select", "arg" => "value", "name" => "select",
"help" => "sélectionner une base de données en particulier" "help" => "sélectionner une base de données en particulier"
@ -96,9 +105,9 @@ abstract class UpdateMigrationsApp extends Application {
protected $overwrite = null; protected $overwrite = null;
protected $verbose = false; protected $verbose = false;
protected $basedir; protected $basedir;
protected $doSql = false; protected $doSql = null;
protected $doDoc = false; protected $doClass = null;
protected $doClass = false; protected $doDoc = null;
protected $select; protected $select;
function main() { function main() {
@ -109,10 +118,12 @@ abstract class UpdateMigrationsApp extends Application {
if ($basedir === null) throw new ValueException("Vous devez spécifier --basedir"); if ($basedir === null) throw new ValueException("Vous devez spécifier --basedir");
$doSql = $this->doSql; $doSql = $this->doSql;
$doDoc = $this->doDoc;
$doClass = $this->doClass; $doClass = $this->doClass;
if (!$doSql && !$doDoc && !$doClass) { $doDoc = $this->doDoc;
$doSql = $doDoc = $doClass = true; if ($doSql === null && $doDoc === null && $doClass === null) {
$doSql = static::DO_SQL;
$doClass = static::DO_CLASS;
$doDoc = static::DO_DOC;
} }
$databases = []; $databases = [];
@ -141,12 +152,12 @@ abstract class UpdateMigrationsApp extends Application {
"do_sql" => $doSql, "do_sql" => $doSql,
"sql_dir" => $database["sql_dir"], "sql_dir" => $database["sql_dir"],
"sql_prefix" => $database["sql_prefix"], "sql_prefix" => $database["sql_prefix"],
"do_doc" => $doDoc,
"doc_dir" => $database["doc_dir"],
"do_class" => $doClass, "do_class" => $doClass,
"class_dir" => $database["class_dir"], "class_dir" => $database["class_dir"],
"class_package" => $database["class_package"], "class_package" => $database["class_package"],
"class_baserow" => $database["class_baserow"], "class_baserow" => $database["class_baserow"],
"do_doc" => $doDoc,
"doc_dir" => $database["doc_dir"],
]); ]);
} }
} }

View File

@ -18,14 +18,6 @@ class MysqlUpdateMigrationsApp extends UpdateMigrationsApp {
"trace" => [$this, "trace"], "trace" => [$this, "trace"],
]); ]);
} }
if ($params["do_doc"]) {
MysqlMigrations::gendoc($class, [
"overwrite" => $overwrite,
"verbose" => $verbose,
"destdir" => "$basedir/$params[doc_dir]",
"trace" => [$this, "trace"],
]);
}
if ($params["do_class"]) { if ($params["do_class"]) {
MysqlMigrations::genclass($class, [ MysqlMigrations::genclass($class, [
"overwrite" => $overwrite, "overwrite" => $overwrite,
@ -36,5 +28,13 @@ class MysqlUpdateMigrationsApp extends UpdateMigrationsApp {
"trace" => [$this, "trace"], "trace" => [$this, "trace"],
]); ]);
} }
if ($params["do_doc"]) {
MysqlMigrations::gendoc($class, [
"overwrite" => $overwrite,
"verbose" => $verbose,
"destdir" => "$basedir/$params[doc_dir]",
"trace" => [$this, "trace"],
]);
}
} }
} }

View File

@ -45,8 +45,8 @@ abstract class CapacitorStorage {
if ($channel->getPrimaryKeys() === null) { if ($channel->getPrimaryKeys() === null) {
$definitions[] = static::PRIMARY_KEY_DEFINITION; $definitions[] = static::PRIMARY_KEY_DEFINITION;
} }
$definitions[] = static::COLUMN_DEFINITIONS;
$definitions[] = $channel->getColumnDefinitions(); $definitions[] = $channel->getColumnDefinitions();
$definitions[] = static::COLUMN_DEFINITIONS;
return cl::merge(...$definitions); return cl::merge(...$definitions);
} }
@ -127,7 +127,9 @@ abstract class CapacitorStorage {
return <<<EOT return <<<EOT
-- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 -- -*- coding: utf-8 mode: sql -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
-- autogénéré à partir de $class -- autogénéré à partir de $class
$sql; $sql;
EOT; EOT;
} }

View File

@ -28,7 +28,7 @@ trait Tcreate {
$definition = "$col $definition"; $definition = "$col $definition";
} }
}; unset($definition); }; unset($definition);
$sql[] = "(\n ".implode("\n, ", $cols).")"; $sql[] = "(\n ".implode("\n, ", $cols)."\n)";
## suffixe ## suffixe
if (($suffix = $query["suffix"] ?? null) !== null) $sql[] = $suffix; if (($suffix = $query["suffix"] ?? null) !== null) $sql[] = $suffix;

View File

@ -83,7 +83,7 @@ class Pdo implements IDatabase {
} }
} }
protected array $dbconn; protected ?array $dbconn;
/** @var array|callable */ /** @var array|callable */
protected array $options; protected array $options;