mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 00:18:25 +00:00
fix: prevent update migration from clearing scopes and resetting specs
This commit is contained in:
parent
8d9abd2f31
commit
101283f345
2 changed files with 8 additions and 87 deletions
|
|
@ -229,11 +229,15 @@ class V21 extends Migration
|
|||
$document->setAttribute('accessedAt', DateTime::now());
|
||||
break;
|
||||
case 'functions':
|
||||
// Add scopes attribute
|
||||
$document->setAttribute('scopes', []);
|
||||
// Set scopes attribute
|
||||
if (empty($document->getAttribute('scopes', []))) {
|
||||
$document->setAttribute('scopes', []);
|
||||
}
|
||||
|
||||
// Add size attribute
|
||||
$document->setAttribute('specification', APP_FUNCTION_SPECIFICATION_DEFAULT);
|
||||
// Set specification attribute
|
||||
if (empty($document->getAttribute('specification'))) {
|
||||
$document->setAttribute('specification', APP_FUNCTION_SPECIFICATION_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
return $document;
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Migration\Version;
|
||||
|
||||
use Appwrite\Migration\Migration;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
|
||||
class V22 extends Migration
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
/**
|
||||
* Disable SubQueries for Performance.
|
||||
*/
|
||||
foreach (['subQueryIndexes', 'subQueryPlatforms', 'subQueryDomains', 'subQueryKeys', 'subQueryWebhooks', 'subQuerySessions', 'subQueryTokens', 'subQueryMemberships', 'subQueryVariables', 'subQueryChallenges', 'subQueryProjectVariables', 'subQueryTargets', 'subQueryTopicTargets'] as $name) {
|
||||
Database::addFilter(
|
||||
$name,
|
||||
fn () => null,
|
||||
fn () => []
|
||||
);
|
||||
}
|
||||
|
||||
Console::info('Migrating Collections');
|
||||
$this->migrateCollections();
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate Collections.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|Throwable
|
||||
*/
|
||||
private function migrateCollections(): void
|
||||
{
|
||||
$internalProjectId = $this->project->getInternalId();
|
||||
$collectionType = match ($internalProjectId) {
|
||||
'console' => 'console',
|
||||
default => 'projects',
|
||||
};
|
||||
|
||||
$collections = $this->collections[$collectionType];
|
||||
foreach ($collections as $collection) {
|
||||
$id = $collection['$id'];
|
||||
|
||||
Console::log("Migrating Collection \"{$id}\"");
|
||||
|
||||
$this->projectDB->setNamespace("_$internalProjectId");
|
||||
|
||||
switch ($id) {
|
||||
case 'installations':
|
||||
// Create personalAccessToken attribute
|
||||
try {
|
||||
$this->createAttributeFromCollection($this->projectDB, $id, 'personalAccessToken');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("'personalAccessToken' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
|
||||
// Create personalAccessTokenExpiry attribute
|
||||
try {
|
||||
$this->createAttributeFromCollection($this->projectDB, $id, 'personalAccessTokenExpiry');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("'personalAccessTokenExpiry' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
|
||||
// Create personalRefreshToken attribute
|
||||
try {
|
||||
$this->createAttributeFromCollection($this->projectDB, $id, 'personalRefreshToken');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("'personalRefreshToken' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue