diff --git a/app/src/Command/DatabaseCommand.php b/app/src/Command/DatabaseCommand.php index 54362b010..84eb84c20 100644 --- a/app/src/Command/DatabaseCommand.php +++ b/app/src/Command/DatabaseCommand.php @@ -91,7 +91,8 @@ public function execute(Arguments $args, ConsoleIo $io) { if($pSchemaConfig) { $io->out(__d('command', 'db.schema.plugin', [$p->plugin])); - $SchemaManager->applySchemaObject($pSchemaConfig); + $SchemaManager->applySchemaObject(schemaObject: $pSchemaConfig, + diffOnly: $args->getOption('not')); } else { $io->out(__d('command', 'db.schema.plugin.none', [$p->plugin])); } diff --git a/app/src/Lib/Util/SchemaManager.php b/app/src/Lib/Util/SchemaManager.php index 5fe8f60c6..7e6f3123b 100644 --- a/app/src/Lib/Util/SchemaManager.php +++ b/app/src/Lib/Util/SchemaManager.php @@ -122,17 +122,25 @@ public function applySchemaFile( * * @since COmanage Registry v5.0.0 * @param object $schemaObject Schema object + * @param bool $diffOnly If true, generate a diff against the current database state, but do not apply it * @param string $tablePrefix String to prefix to table names */ - public function applySchemaObject(object $schemaObject, string $tablePrefix="") { + public function applySchemaObject( + object $schemaObject, + bool $diffOnly=false, + string $tablePrefix="" + ) { if(!$this->columnLibrary) { // We need the column library from the core config - $this->applySchemaFile(schemaFile: ROOT . DS . 'config' . DS . 'schema' . DS . 'schema.json', - parseOnly: true); + $this->applySchemaFile( + schemaFile: ROOT . DS . 'config' . DS . 'schema' . DS . 'schema.json', + parseOnly: true, + diffOnly: $diffOnly + ); } - $this->processSchema(schemaConfig: $schemaObject, tablePrefix: $tablePrefix); + $this->processSchema(schemaConfig: $schemaObject, diffOnly: $diffOnly, tablePrefix: $tablePrefix); } /**