diff --git a/packages/mango/Doctrine/SchemaProvider.php b/packages/mango/Doctrine/SchemaProvider.php index 706ecd2..a4da6fb 100644 --- a/packages/mango/Doctrine/SchemaProvider.php +++ b/packages/mango/Doctrine/SchemaProvider.php @@ -7,6 +7,7 @@ use Closure; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Result; +use Doctrine\DBAL\Schema\PostgreSQLSchemaManager; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\Provider\SchemaProvider as SchemaProviderInterface; use InvalidArgumentException; @@ -91,6 +92,14 @@ public function createSchema(): Schema $schema = new Schema(schemaConfig: $schemaManager->createSchemaConfig()); + if ($schemaManager instanceof PostgreSQLSchemaManager) { + foreach ($schemaManager->listSchemaNames() as $namespace) { + if (! $schema->hasNamespace($namespace)) { + $schema->createNamespace($namespace); + } + } + } + foreach ($this->tableBuilders as $tableBuilder) { $table = new Table($schema->createTable($name = $tableBuilder->getName())); $tableBuilder->build($table);