Skip to content

Commit 408c8af

Browse files
committed
move schema creation into create collection
1 parent 140d3f4 commit 408c8af

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/Client.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Patchlevel\Rango\Model\DatabaseInfo;
1010
use Patchlevel\Rango\Sql\Identifier;
1111
use PDO;
12-
1312
use function sprintf;
1413

1514
final class Client
@@ -32,8 +31,6 @@ public function __construct(string|PDO $uri)
3231

3332
public function getDatabase(string $name): Database
3433
{
35-
SqlRunner::exec($this->pdo, sprintf('CREATE SCHEMA IF NOT EXISTS %s', Identifier::quote($name)));
36-
3734
return new Database($this, $name);
3835
}
3936

src/Operation/CreateCollection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public function execute(PDO $pdo, QueryBuilder $queryBuilder): bool
2828
SqlRunner::exec(
2929
$pdo,
3030
sprintf(
31-
'CREATE TABLE IF NOT EXISTS %s.%s (_id TEXT PRIMARY KEY, data JSONB NOT NULL)',
31+
'CREATE SCHEMA IF NOT EXISTS %s; CREATE TABLE IF NOT EXISTS %s.%s (_id TEXT PRIMARY KEY, data JSONB NOT NULL);',
32+
$schema,
3233
$schema,
3334
$table,
3435
),

0 commit comments

Comments
 (0)