Merge branch 'main' of https://github.com/appwrite/appwrite into limit-ping-counts

This commit is contained in:
fogelito committed 2026-07-07 19:07:20 +03:00
commit 7d0c012a1d
2 files changed
+57

No files matched your search

+18
View File
@@ -2662,6 +2662,17 @@ return [
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('folder'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 2048,
'signed' => true,
'required' => false,
'default' => '',
'array' => false,
'filters' => [],
],
[
'$id' => ID::custom('signature'),
'type' => Database::VAR_STRING,
@@ -2850,6 +2861,13 @@ return [
'lengths' => [256],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_folder'),
'type' => Database::INDEX_KEY,
'attributes' => ['folder'],
'lengths' => [256],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_signature'),
'type' => Database::INDEX_KEY,
+39
View File
@@ -7,6 +7,8 @@ use Exception;
use Throwable;
use Utopia\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Exception\Duplicate;
class V25 extends Migration
{
@@ -17,6 +19,9 @@ class V25 extends Migration
{
Console::info('Migrating collections');
$this->migrateCollections();
Console::info('Migrating buckets');
$this->migrateBuckets();
}
/**
@@ -66,4 +71,38 @@ class V25 extends Migration
}
}
}
/**
* Add the virtual folder `folder` attribute and index to every
* per-bucket files collection.
*
* @return void
* @throws Throwable
*/
private function migrateBuckets(): void
{
$this->dbForProject->foreach('buckets', function (Document $bucket) {
$bucketTable = "bucket_{$bucket->getSequence()}";
Console::log("Migrating Bucket {$bucket->getId()} ({$bucket->getAttribute('name')})");
try {
$this->createAttributeFromCollection($this->dbForProject, $bucketTable, 'folder', 'files');
} catch (Duplicate) {
Console::warning("'folder' from {$bucketTable}: Column already exists");
} catch (Throwable $th) {
Console::warning("'folder' from {$bucketTable}: {$th->getMessage()}");
}
try {
$this->createIndexFromCollection($this->dbForProject, $bucketTable, '_key_folder', 'files');
} catch (Duplicate) {
Console::warning("'_key_folder' from {$bucketTable}: Index already exists");
} catch (Throwable $th) {
Console::warning("'_key_folder' from {$bucketTable}: {$th->getMessage()}");
}
$this->dbForProject->purgeCachedCollection($bucketTable);
$this->dbForProject->purgeCachedDocument(Database::METADATA, $bucketTable);
});
}
}