fix(vcs): add missing attributes to 1.6.x migration

This commit is contained in:
Steven Nguyen 2025-04-25 16:06:35 -07:00
parent 70f31bb48c
commit 8d9abd2f31
No known key found for this signature in database
2 changed files with 57 additions and 2 deletions

View file

@ -92,7 +92,7 @@ abstract class Migration
'1.5.11' => 'V20',
'1.6.0' => 'V21',
'1.6.1' => 'V21',
'1.6.2' => 'V22',
'1.6.2' => 'V21',
];
/**
@ -374,6 +374,10 @@ abstract class Migration
default => 'projects',
};
if ($from === 'files') {
$collectionType = 'buckets';
}
$collection = $this->collections[$collectionType][$from] ?? null;
if (is_null($collection)) {

View file

@ -74,6 +74,27 @@ class V21 extends Migration
Console::warning("'accessedAt' from {$id}: {$th->getMessage()}");
}
break;
case 'rules':
$attributesToCreate = ['owner', 'region'];
foreach ($attributesToCreate as $attribute) {
// Create attribute
try {
$this->createAttributeFromCollection($this->projectDB, $id, $attribute);
} catch (Throwable $th) {
Console::warning("'$attribute' from {$id}: {$th->getMessage()}");
}
}
$indexesToCreate = ['_key_owner', '_key_region'];
foreach ($indexesToCreate as $index) {
// Create index
try {
$this->createIndexFromCollection($this->projectDB, $id, $index);
} catch (Throwable $th) {
Console::warning("'$index' from {$id}: {$th->getMessage()}");
}
}
break;
case 'platforms':
// Increase 'type' length to 255
try {
@ -82,6 +103,17 @@ class V21 extends Migration
Console::warning("'type' from {$id}: {$th->getMessage()}");
}
break;
case 'installations':
$attributesToCreate = ['personalAccessToken', 'personalAccessTokenExpiry', 'personalRefreshToken'];
foreach ($attributesToCreate as $attribute) {
// Create attribute
try {
$this->createAttributeFromCollection($this->projectDB, $id, $attribute);
} catch (Throwable $th) {
Console::warning("'$attribute' from {$id}: {$th->getMessage()}");
}
}
break;
case 'migrations':
// Create destination attribute
try {
@ -217,11 +249,30 @@ class V21 extends Migration
foreach ($this->documentsIterator('buckets') as $bucket) {
$bucketId = 'bucket_' . $bucket['$internalId'];
Console::log("Migrating Bucket {$bucketId} {$bucket->getId()} ({$bucket->getAttribute('name')})");
try {
$this->projectDB->updateAttribute($bucketId, 'metadata', size: 65534);
} catch (\Throwable $th) {
Console::warning("'metadata' from {$bucketId}: {$th->getMessage()}");
}
try {
$this->createAttributeFromCollection($this->projectDB, $bucketId, 'transformedAt', 'files');
} catch (\Throwable $th) {
Console::warning("'transformedAt' from {$bucketId}: {$th->getMessage()}");
}
try {
$this->createIndexFromCollection($this->projectDB, $bucketId, '_key_transformedAt', 'files');
} catch (\Throwable $th) {
Console::warning("'_key_transformedAt' from {$bucketId}: {$th->getMessage()}");
}
try {
$this->projectDB->purgeCachedCollection($bucketId);
} catch (\Throwable $th) {
Console::warning("'bucketId' from {$bucketId}: {$th->getMessage()}");
Console::warning("purging {$bucketId}: {$th->getMessage()}");
}
}
}