From 490424c20162791fe8edb757b1c53b6035d03c3e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 21 Feb 2025 00:43:38 +1300 Subject: [PATCH] Add missing audit setup --- app/http.php | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/app/http.php b/app/http.php index 315e5f158f..ca1eb8e509 100644 --- a/app/http.php +++ b/app/http.php @@ -200,25 +200,8 @@ function createDatabase(App $app, string $resourceKey, string $dbName, array $co Console::info(" └── Creating collection: {$collection['$id']}..."); - $attributes = array_map(fn ($attr) => new Document([ - '$id' => ID::custom($attr['$id']), - 'type' => $attr['type'], - 'size' => $attr['size'], - 'required' => $attr['required'], - 'signed' => $attr['signed'], - 'array' => $attr['array'], - 'filters' => $attr['filters'], - 'default' => $attr['default'] ?? null, - 'format' => $attr['format'] ?? '' - ]), $collection['attributes']); - - $indexes = array_map(fn ($index) => new Document([ - '$id' => ID::custom($index['$id']), - 'type' => $index['type'], - 'attributes' => $index['attributes'], - 'lengths' => $index['lengths'], - 'orders' => $index['orders'], - ]), $collection['indexes']); + $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); + $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); $database->createCollection($key, $attributes, $indexes); } @@ -330,6 +313,11 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg Console::success('[Setup] - Skip: metadata table already exists'); } + if ($dbForProject->getCollection(Audit::COLLECTION)->isEmpty()) { + $audit = new Audit($dbForProject); + $audit->setup(); + } + foreach ($projectCollections as $key => $collection) { if (($collection['$collection'] ?? '') !== Database::METADATA) { continue;