Skip to content

Commit

Permalink
Update index order
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Nov 6, 2024
1 parent 4688aef commit a23aec2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ public function createCollection(string $name, array $attributes = [], array $in
if ($this->sharedTables) {
$collection .= "
_tenant INT(11) UNSIGNED DEFAULT NULL,
UNIQUE KEY _uid (_tenant, _uid),
KEY _created_at (_tenant, _createdAt),
KEY _updated_at (_tenant, _updatedAt),
KEY _tenant_id (_tenant, _id)
UNIQUE KEY _uid (_uid, _tenant),
KEY _created_at (_createdAt, _tenant),
KEY _updated_at (_updatedAt, _tenant),
KEY _tenant_id (_id, _tenant)
";
} 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)} (_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);
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);
";
} else {
$collection .= "
Expand Down

0 comments on commit a23aec2

Please sign in to comment.