@@ -177,7 +177,7 @@ public function addCollection(string $collectionName, Index ...$indices): void
177177 public function dropCollection (string $ collectionName ): void
178178 {
179179 $ cmd = <<<EOT
180- DROP TABLE {$ this ->tableName ($ collectionName )};
180+ DROP TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )};
181181EOT ;
182182
183183 $ this ->transactional (function () use ($ cmd ) {
@@ -191,6 +191,7 @@ public function hasCollectionIndex(string $collectionName, string $indexName): b
191191SELECT INDEXNAME
192192FROM pg_indexes
193193WHERE TABLENAME = ' {$ this ->tableName ($ collectionName )}'
194+ AND SCHEMANAME = ' {$ this ->schemaName ($ collectionName )}'
194195AND INDEXNAME = ' $ indexName'
195196EOT ;
196197
@@ -223,7 +224,7 @@ public function addCollectionIndex(string $collectionName, Index $index): void
223224 $ columnsSql = substr ($ columnsSql , 2 );
224225
225226 $ metadataColumnCmd = <<<EOT
226- ALTER TABLE {$ this ->tableName ($ collectionName )}
227+ ALTER TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
227228 $ columnsSql;
228229EOT ;
229230
@@ -263,7 +264,7 @@ public function dropCollectionIndex(string $collectionName, $index): void
263264 $ columnsSql = substr ($ columnsSql , 2 );
264265
265266 $ metadataColumnCmd = <<<EOT
266- ALTER TABLE {$ this ->tableName ($ collectionName )}
267+ ALTER TABLE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
267268 $ columnsSql;
268269EOT ;
269270 $ index = $ index ->indexCmd ();
@@ -313,7 +314,9 @@ public function addDoc(string $collectionName, string $docId, array $doc): void
313314 }
314315
315316 $ 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+ );
317320EOT ;
318321
319322 $ this ->transactional (function () use ($ cmd , $ docId , $ doc , $ metadata ) {
@@ -346,7 +349,7 @@ public function updateDoc(string $collectionName, string $docId, array $docOrSub
346349 }
347350
348351 $ cmd = <<<EOT
349- UPDATE {$ this ->tableName ($ collectionName )}
352+ UPDATE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
350353SET doc = (to_jsonb(doc) || :doc) {$ metadataStr }
351354WHERE id = :id
352355;
@@ -385,7 +388,7 @@ public function updateMany(string $collectionName, Filter $filter, array $set):
385388 }
386389
387390 $ cmd = <<<EOT
388- UPDATE {$ this ->tableName ($ collectionName )}
391+ UPDATE {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
389392SET doc = (to_jsonb(doc) || :doc) {$ metadataStr }
390393$ where;
391394EOT ;
@@ -425,7 +428,7 @@ public function upsertDoc(string $collectionName, string $docId, array $docOrSub
425428 public function deleteDoc (string $ collectionName , string $ docId ): void
426429 {
427430 $ cmd = <<<EOT
428- DELETE FROM {$ this ->tableName ($ collectionName )}
431+ DELETE FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
429432WHERE id = :id
430433EOT ;
431434
@@ -448,7 +451,7 @@ public function deleteMany(string $collectionName, Filter $filter): void
448451 $ where = $ filterStr ? "WHERE $ filterStr " : '' ;
449452
450453 $ cmd = <<<EOT
451- DELETE FROM {$ this ->tableName ($ collectionName )}
454+ DELETE FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
452455$ where;
453456EOT ;
454457
@@ -466,7 +469,7 @@ public function getDoc(string $collectionName, string $docId): ?array
466469 {
467470 $ query = <<<EOT
468471SELECT doc
469- FROM {$ this ->tableName ($ collectionName )}
472+ FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
470473WHERE id = :id
471474EOT ;
472475 $ stmt = $ this ->connection ->prepare ($ query );
@@ -503,7 +506,7 @@ public function filterDocs(string $collectionName, Filter $filter, int $skip = n
503506
504507 $ query = <<<EOT
505508SELECT doc
506- FROM {$ this ->tableName ($ collectionName )}
509+ FROM {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
507510$ where
508511$ orderBy
509512$ limit
@@ -702,7 +705,7 @@ private function indexToSqlCmd(Index $index, string $collectionName): string
702705 $ name = $ index ->name () ?? '' ;
703706
704707 $ cmd = <<<EOT
705- CREATE $ type $ name ON {$ this ->tableName ($ collectionName )}
708+ CREATE $ type $ name ON {$ this ->schemaName ( $ collectionName )} . { $ this -> tableName ($ collectionName )}
706709$ fields;
707710EOT ;
708711
0 commit comments