@@ -177,7 +177,7 @@ public function addCollection(string $collectionName, Index ...$indices): void
177
177
public function dropCollection (string $ collectionName ): void
178
178
{
179
179
$ cmd = <<<EOT
180
- DROP TABLE {$ this ->tableName ($ collectionName )};
180
+ DROP TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )};
181
181
EOT ;
182
182
183
183
$ this ->transactional (function () use ($ cmd ) {
@@ -191,6 +191,7 @@ public function hasCollectionIndex(string $collectionName, string $indexName): b
191
191
SELECT INDEXNAME
192
192
FROM pg_indexes
193
193
WHERE TABLENAME = ' {$ this ->tableName ($ collectionName )}'
194
+ AND SCHEMANAME = ' {$ this ->schemaName ($ collectionName )}'
194
195
AND INDEXNAME = ' $ indexName'
195
196
EOT ;
196
197
@@ -223,7 +224,7 @@ public function addCollectionIndex(string $collectionName, Index $index): void
223
224
$ columnsSql = substr ($ columnsSql , 2 );
224
225
225
226
$ metadataColumnCmd = <<<EOT
226
- ALTER TABLE {$ this ->tableName ($ collectionName )}
227
+ ALTER TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
227
228
$ columnsSql;
228
229
EOT ;
229
230
@@ -263,7 +264,7 @@ public function dropCollectionIndex(string $collectionName, $index): void
263
264
$ columnsSql = substr ($ columnsSql , 2 );
264
265
265
266
$ metadataColumnCmd = <<<EOT
266
- ALTER TABLE {$ this ->tableName ($ collectionName )}
267
+ ALTER TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
267
268
$ columnsSql;
268
269
EOT ;
269
270
$ index = $ index ->indexCmd ();
@@ -313,7 +314,9 @@ public function addDoc(string $collectionName, string $docId, array $doc): void
313
314
}
314
315
315
316
$ cmd = <<<EOT
316
- INSERT INTO {$ this ->tableName ($ collectionName )} (id, doc {$ metadataKeysStr }) VALUES (:id, :doc {$ metadataValsStr });
317
+ INSERT INTO {$ this ->schemaName ($ collectionName )}. {$ this ->tableName ($ collectionName )} (
318
+ id, doc {$ metadataKeysStr }) VALUES (:id, :doc {$ metadataValsStr }
319
+ );
317
320
EOT ;
318
321
319
322
$ this ->transactional (function () use ($ cmd , $ docId , $ doc , $ metadata ) {
@@ -346,7 +349,7 @@ public function updateDoc(string $collectionName, string $docId, array $docOrSub
346
349
}
347
350
348
351
$ cmd = <<<EOT
349
- UPDATE {$ this ->tableName ($ collectionName )}
352
+ UPDATE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
350
353
SET doc = (to_jsonb(doc) || :doc) {$ metadataStr }
351
354
WHERE id = :id
352
355
;
@@ -385,7 +388,7 @@ public function updateMany(string $collectionName, Filter $filter, array $set):
385
388
}
386
389
387
390
$ cmd = <<<EOT
388
- UPDATE {$ this ->tableName ($ collectionName )}
391
+ UPDATE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
389
392
SET doc = (to_jsonb(doc) || :doc) {$ metadataStr }
390
393
$ where;
391
394
EOT ;
@@ -425,7 +428,7 @@ public function upsertDoc(string $collectionName, string $docId, array $docOrSub
425
428
public function deleteDoc (string $ collectionName , string $ docId ): void
426
429
{
427
430
$ cmd = <<<EOT
428
- DELETE FROM {$ this ->tableName ($ collectionName )}
431
+ DELETE FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
429
432
WHERE id = :id
430
433
EOT ;
431
434
@@ -448,7 +451,7 @@ public function deleteMany(string $collectionName, Filter $filter): void
448
451
$ where = $ filterStr ? "WHERE $ filterStr " : '' ;
449
452
450
453
$ cmd = <<<EOT
451
- DELETE FROM {$ this ->tableName ($ collectionName )}
454
+ DELETE FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
452
455
$ where;
453
456
EOT ;
454
457
@@ -466,7 +469,7 @@ public function getDoc(string $collectionName, string $docId): ?array
466
469
{
467
470
$ query = <<<EOT
468
471
SELECT doc
469
- FROM {$ this ->tableName ($ collectionName )}
472
+ FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
470
473
WHERE id = :id
471
474
EOT ;
472
475
$ stmt = $ this ->connection ->prepare ($ query );
@@ -503,7 +506,7 @@ public function filterDocs(string $collectionName, Filter $filter, int $skip = n
503
506
504
507
$ query = <<<EOT
505
508
SELECT doc
506
- FROM {$ this ->tableName ($ collectionName )}
509
+ FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
507
510
$ where
508
511
$ orderBy
509
512
$ limit
@@ -702,7 +705,7 @@ private function indexToSqlCmd(Index $index, string $collectionName): string
702
705
$ name = $ index ->name () ?? '' ;
703
706
704
707
$ cmd = <<<EOT
705
- CREATE $ type $ name ON {$ this ->tableName ($ collectionName )}
708
+ CREATE $ type $ name ON {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
706
709
$ fields;
707
710
EOT ;
708
711
0 commit comments