Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/tasks/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 12 additions & 9 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down