Skip to content

Commit

Permalink
Merge pull request #480 from utopia-php/0.53.x-tenant-indexes
Browse files Browse the repository at this point in the history
sharedTables index
  • Loading branch information
abnegate authored Nov 12, 2024
2 parents e43f8ee + 7f264cb commit 744ff4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ public function createCollection(string $name, array $attributes = [], array $in
$collection .= "
_tenant INT(11) UNSIGNED DEFAULT NULL,
UNIQUE KEY _uid (_uid, _tenant),
KEY _created_at (_createdAt, _tenant),
KEY _updated_at (_updatedAt, _tenant),
KEY _tenant_id (_id, _tenant)
KEY _created_at (_tenant, _createdAt),
KEY _updated_at (_tenant, _updatedAt),
KEY _tenant_id (_tenant, _id)
";
} else {
$collection .= "
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public function createCollection(string $name, array $attributes = [], array $in
if ($this->sharedTables) {
$collection .= "
CREATE UNIQUE INDEX \"{$namespace}_{$this->tenant}_{$id}_uid\" ON {$this->getSQLTable($id)} (LOWER(_uid), _tenant);
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_created\" ON {$this->getSQLTable($id)} (\"_createdAt\", _tenant);
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_updated\" ON {$this->getSQLTable($id)} (\"_updatedAt\", _tenant);
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_tenant_id\" ON {$this->getSQLTable($id)} (_id, _tenant);
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_created\" ON {$this->getSQLTable($id)} (_tenant, \"_createdAt\");
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_updated\" ON {$this->getSQLTable($id)} (_tenant, \"_updatedAt\");
CREATE INDEX \"{$namespace}_{$this->tenant}_{$id}_tenant_id\" ON {$this->getSQLTable($id)} (_tenant, _id);
";
} else {
$collection .= "
Expand Down

0 comments on commit 744ff4a

Please sign in to comment.