diff --git a/nur_src/m/cli/UpdateMigrationsApp.php b/nur_src/m/cli/UpdateMigrationsApp.php index 08d0168..ab902c1 100644 --- a/nur_src/m/cli/UpdateMigrationsApp.php +++ b/nur_src/m/cli/UpdateMigrationsApp.php @@ -43,6 +43,15 @@ abstract class UpdateMigrationsApp extends Application { */ 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 = [ "basedir" => ["?string", null, "chemin absolu du projet"], "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"], "sql_dir" => ["?string", 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_package" => ["?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); @@ -77,12 +86,12 @@ abstract class UpdateMigrationsApp extends Application { ["-s", "--sql-only", "name" => "do_sql", "value" => true, "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, "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", ["-l", "--select", "arg" => "value", "name" => "select", "help" => "sélectionner une base de données en particulier" @@ -96,9 +105,9 @@ abstract class UpdateMigrationsApp extends Application { protected $overwrite = null; protected $verbose = false; protected $basedir; - protected $doSql = false; - protected $doDoc = false; - protected $doClass = false; + protected $doSql = null; + protected $doClass = null; + protected $doDoc = null; protected $select; function main() { @@ -109,10 +118,12 @@ abstract class UpdateMigrationsApp extends Application { if ($basedir === null) throw new ValueException("Vous devez spécifier --basedir"); $doSql = $this->doSql; - $doDoc = $this->doDoc; $doClass = $this->doClass; - if (!$doSql && !$doDoc && !$doClass) { - $doSql = $doDoc = $doClass = true; + $doDoc = $this->doDoc; + if ($doSql === null && $doDoc === null && $doClass === null) { + $doSql = static::DO_SQL; + $doClass = static::DO_CLASS; + $doDoc = static::DO_DOC; } $databases = []; @@ -141,12 +152,12 @@ abstract class UpdateMigrationsApp extends Application { "do_sql" => $doSql, "sql_dir" => $database["sql_dir"], "sql_prefix" => $database["sql_prefix"], - "do_doc" => $doDoc, - "doc_dir" => $database["doc_dir"], "do_class" => $doClass, "class_dir" => $database["class_dir"], "class_package" => $database["class_package"], "class_baserow" => $database["class_baserow"], + "do_doc" => $doDoc, + "doc_dir" => $database["doc_dir"], ]); } } diff --git a/nur_src/m/pdo/mysql/MysqlUpdateMigrationsApp.php b/nur_src/m/pdo/mysql/MysqlUpdateMigrationsApp.php index 8f8b771..0f9015d 100644 --- a/nur_src/m/pdo/mysql/MysqlUpdateMigrationsApp.php +++ b/nur_src/m/pdo/mysql/MysqlUpdateMigrationsApp.php @@ -18,14 +18,6 @@ class MysqlUpdateMigrationsApp extends UpdateMigrationsApp { "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"]) { MysqlMigrations::genclass($class, [ "overwrite" => $overwrite, @@ -36,5 +28,13 @@ class MysqlUpdateMigrationsApp extends UpdateMigrationsApp { "trace" => [$this, "trace"], ]); } + if ($params["do_doc"]) { + MysqlMigrations::gendoc($class, [ + "overwrite" => $overwrite, + "verbose" => $verbose, + "destdir" => "$basedir/$params[doc_dir]", + "trace" => [$this, "trace"], + ]); + } } } diff --git a/src/db/CapacitorStorage.php b/src/db/CapacitorStorage.php index 4d14df5..ceceb9c 100644 --- a/src/db/CapacitorStorage.php +++ b/src/db/CapacitorStorage.php @@ -45,8 +45,8 @@ abstract class CapacitorStorage { if ($channel->getPrimaryKeys() === null) { $definitions[] = static::PRIMARY_KEY_DEFINITION; } - $definitions[] = static::COLUMN_DEFINITIONS; $definitions[] = $channel->getColumnDefinitions(); + $definitions[] = static::COLUMN_DEFINITIONS; return cl::merge(...$definitions); } @@ -127,7 +127,9 @@ abstract class CapacitorStorage { return <<