added migration to self hosted version

This commit is contained in:
ArnabChatterjee20k 2025-08-05 19:34:19 +05:30
parent 0fddbd5caa
commit 7d798f5373
2 changed files with 62 additions and 0 deletions

View file

@ -89,6 +89,7 @@ abstract class Migration
'1.7.2' => 'V22',
'1.7.3' => 'V22',
'1.7.4' => 'V22',
'1.8.0' => 'V23'
];
/**

View file

@ -0,0 +1,61 @@
<?php
namespace Appwrite\Migration\Version;
use Appwrite\ID;
use Appwrite\Migration\Migration;
use Exception;
use Throwable;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
class V23 extends Migration
{
/**
* @throws Throwable
*/
public function execute(): void
{
/**
* Disable SubQueries for Performance.
*/
foreach (['subQueryIndexes', 'subQueryPlatforms', 'subQueryDomains', 'subQueryKeys', 'subQueryDevKeys', 'subQueryWebhooks', 'subQuerySessions', 'subQueryTokens', 'subQueryMemberships', 'subQueryVariables', 'subQueryChallenges', 'subQueryProjectVariables', 'subQueryTargets', 'subQueryTopicTargets'] as $name) {
Database::addFilter(
$name,
fn () => null,
fn () => []
);
}
Console::info('Migrating databases');
$this->migrateDatabases();
}
/**
* Migrate Databases.
*
* @return void
* @throws Exception|Throwable
*/
private function migrateDatabases(): void
{
if ($this->project->getId() === 'console') {
return;
}
// since required + default can't be used together
// so first creating the attribute then bulk updating the attribute
$this->dbForProject->createAttributes('databases', [new Document([
'$id' => ID::custom('type'),
'type' => Database::VAR_STRING,
'size' => 128,
'required' => true,
'signed' => true,
'array' => false,
'filters' => [],
])]);
$this->dbForProject->updateDocuments('databases', new Document(['$id' => 'type','type' => 'sql']));
}
}