Skip to content

Commit

Permalink
Fix handling of -n for plugin schemas (CFM-27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed May 24, 2025
1 parent a2f15b4 commit e5e2907
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/src/Command/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
Expand Down
16 changes: 12 additions & 4 deletions app/src/Lib/Util/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit e5e2907

Please sign in to comment.