From 57ceaf79bac44ed2ed8fef6ecc5e2b0fbb9758f7 Mon Sep 17 00:00:00 2001 From: marc Date: Tue, 3 Dec 2024 14:42:09 +0100 Subject: [PATCH] allow option to migrate workspaces and external schemas --- src/Config.php | 10 ++++++++++ src/Configuration/ConfigDefinition.php | 2 ++ src/Strategy/DatabaseMigrate.php | 8 ++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Config.php b/src/Config.php index f133504..9882fce 100644 --- a/src/Config.php +++ b/src/Config.php @@ -203,4 +203,14 @@ public function isSourceByodb(): bool { return (bool) $this->getValue(['parameters', 'isSourceByodb']); } + + public function getIncludedWorkspaceSchemas(): array + { + return $this->getArrayValue(['parameters', 'includeWorkspaceSchemas']); + } + + public function getIncludedExternalSchemas(): array + { + return $this->getArrayValue(['parameters', 'includeExternalSchemas']); + } } diff --git a/src/Configuration/ConfigDefinition.php b/src/Configuration/ConfigDefinition.php index b1f43b6..d801b61 100644 --- a/src/Configuration/ConfigDefinition.php +++ b/src/Configuration/ConfigDefinition.php @@ -22,6 +22,8 @@ protected function getParametersDefinition(): ArrayNodeDefinition ->scalarNode('sourceByodb')->end() ->scalarNode('sourceKbcUrl')->isRequired()->cannotBeEmpty()->end() ->scalarNode('#sourceKbcToken')->isRequired()->cannotBeEmpty()->end() + ->arrayNode('includeWorkspaceSchemas')->prototype('scalar')->end()->end() + ->arrayNode('includeExternalSchemas')->prototype('scalar')->end()->end() ->arrayNode('tables')->prototype('scalar')->end()->end() ->arrayNode('db') ->children() diff --git a/src/Strategy/DatabaseMigrate.php b/src/Strategy/DatabaseMigrate.php index e2d5a21..6c2904c 100644 --- a/src/Strategy/DatabaseMigrate.php +++ b/src/Strategy/DatabaseMigrate.php @@ -81,11 +81,15 @@ public function migrate(Config $config): void if (in_array($schemaName, self::SKIP_CLONE_SCHEMAS, true)) { continue; } - if (str_starts_with($schemaName, 'WORKSPACE')) { + if (str_starts_with($schemaName, 'WORKSPACE') + && !in_array($schemaName, $config->getIncludedWorkspaceSchemas())) { + continue; } - if (!$this->sourceSapiClient->bucketExists($schemaName)) { + if (!$this->sourceSapiClient->bucketExists($schemaName) + && !in_array($schemaName, $config->getIncludedExternalSchemas())) { + continue; }