diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index e45189713..425360985 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -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 .= " diff --git a/src/Database/Adapter/Postgres.php b/src/Database/Adapter/Postgres.php index 2bb044431..817ca3e2a 100644 --- a/src/Database/Adapter/Postgres.php +++ b/src/Database/Adapter/Postgres.php @@ -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 .= "