diff --git a/bin/tasks/load.php b/bin/tasks/load.php index 2a04a9290..3f7c6eba8 100644 --- a/bin/tasks/load.php +++ b/bin/tasks/load.php @@ -246,6 +246,7 @@ function addArticle($database, Generator $faker): void // Three random users out of 10,000 get mutate access '$permissions' => [ + Permission::read(Role::any()), Permission::read(Role::user($faker->randomNumber(4))), Permission::read(Role::user($faker->randomNumber(4))), Permission::read(Role::user($faker->randomNumber(4))), diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index a676f9acb..6fedc6add 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -128,7 +128,7 @@ public function createCollection(string $name, array $attributes = [], array $in `_document` VARCHAR(255) NOT NULL, PRIMARY KEY (`_id`), UNIQUE INDEX `_index1` (`_document`,`_type`,`_permission`), - INDEX `_permission` (`_permission`) + INDEX `_permission` (`_permission`,`_type`,`_document`) )") ->execute(); } catch (\Exception $th) { diff --git a/src/Database/Adapter/Postgres.php b/src/Database/Adapter/Postgres.php index fb569c85f..366c612a8 100644 --- a/src/Database/Adapter/Postgres.php +++ b/src/Database/Adapter/Postgres.php @@ -109,15 +109,18 @@ public function createCollection(string $name, array $attributes = [], array $in $stmt->execute(); $stmtIndex->execute(); - $this->getPDO()->prepare(" - CREATE TABLE IF NOT EXISTS {$this->getSQLTable($id . '_perms')} ( - \"_id\" SERIAL NOT NULL, - \"_type\" VARCHAR(12) NOT NULL, - \"_permission\" VARCHAR(255) NOT NULL, - \"_document\" VARCHAR(255) NOT NULL, - PRIMARY KEY (\"_id\") - ); - ")->execute(); + $this->getPDO() + ->prepare("CREATE TABLE IF NOT EXISTS {$this->getSQLTable($id . '_perms')} ( + \"_id\" SERIAL NOT NULL, + \"_type\" VARCHAR(12) NOT NULL, + \"_permission\" VARCHAR(255) NOT NULL, + \"_document\" VARCHAR(255) NOT NULL, + PRIMARY KEY (\"_id\") + ); + CREATE UNIQUE INDEX \"index_{$namespace}_{$id}_ukey\" ON {$this->getSQLTable($id. '_perms')} USING btree (\"_document\",\"_type\",\"_permission\"); + CREATE INDEX \"index_{$namespace}_{$id}_permission\" ON {$this->getSQLTable($id. '_perms')} USING btree (\"_permission\",\"_type\",\"_document\"); + ") + ->execute(); foreach ($indexes as $index) { $indexId = $this->filter($index->getId());