1
0
Fork 0
mirror of synced 2024-06-15 17:24:48 +12:00

update console db for default buckets

This commit is contained in:
Damodar Lohani 2021-12-23 14:43:11 +05:45
parent 535bdee74a
commit b6d0607c72

View file

@ -128,6 +128,60 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
$dbForConsole->createCollection($key, $attributes, $indexes);
}
Console::success('[Setup] - Creating default bucket...');
$dbForConsole->createDocument('buckets', new Document([
'$id' => 'default',
'$collection' => 'buckets',
'dateCreated' => \time(),
'dateUpdated' => \time(),
'name' => 'Default',
'permission' => 'file',
'maximumFileSize' => App::getEnv('_APP_STORAGE_LIMIT', 0), // 10MB
'allowedFileExtensions' => [],
'enabled' => true,
'adapter' => '',
'encryption' => true,
'antiVirus' => true,
'$read' => [],
'$write' => [],
'search' => 'buckets Default',
]));
Console::success('[Setup] - Creating files collection for default bucket...');
$files = $collections['file'] ?? [];
if(empty($files)) {
throw new Exception('Files collection is not configured.');
}
$attributes = [];
$indexes = [];
foreach ($files['attributes'] as $attribute) {
$attributes[] = new Document([
'$id' => $attribute['$id'],
'type' => $attribute['type'],
'size' => $attribute['size'],
'required' => $attribute['required'],
'signed' => $attribute['signed'],
'array' => $attribute['array'],
'filters' => $attribute['filters'],
]);
}
foreach ($files['indexes'] as $index) {
$indexes[] = new Document([
'$id' => $index['$id'],
'type' => $index['type'],
'attributes' => $index['attributes'],
'lengths' => $index['lengths'],
'orders' => $index['orders'],
]);
}
$dbForExternal = $app->getResource('dbForExternal'); /** @var Utopia\Database\Database $dbForExternal */
$dbForExternal->createCollection('bucket_' . 'default', $attributes, $indexes);
Console::success('[Setup] - Server database init completed...');
}
});