mirror of
https://github.com/appwrite/appwrite
synced 2026-05-16 21:48:45 +00:00
chore: shifted migration to 1.7.0
This commit is contained in:
parent
9a4220f2dd
commit
e80bc2bb39
3 changed files with 70 additions and 8 deletions
|
|
@ -93,6 +93,7 @@ abstract class Migration
|
|||
'1.6.0' => 'V21',
|
||||
'1.6.1' => 'V21',
|
||||
'1.6.2' => 'V22',
|
||||
'1.7.0' => 'V23',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -75,14 +75,6 @@ class V22 extends Migration
|
|||
Console::warning("'personalRefreshToken' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
break;
|
||||
case 'memberships':
|
||||
// Create roles index
|
||||
try {
|
||||
$this->createIndexFromCollection($this->projectDB, $id, '_key_roles');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("'_key_roles' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
|
|
|
|||
69
src/Appwrite/Migration/Version/V23.php
Normal file
69
src/Appwrite/Migration/Version/V23.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Migration\Version;
|
||||
|
||||
use Appwrite\Migration\Migration;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
|
||||
class V23 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 'memberships':
|
||||
// Create roles index
|
||||
try {
|
||||
$this->createIndexFromCollection($this->projectDB, $id, '_key_roles');
|
||||
} catch (Throwable $th) {
|
||||
Console::warning("'_key_roles' from {$id}: {$th->getMessage()}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue