mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
added migration to self hosted version
This commit is contained in:
parent
0fddbd5caa
commit
7d798f5373
2 changed files with 62 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ abstract class Migration
|
|||
'1.7.2' => 'V22',
|
||||
'1.7.3' => 'V22',
|
||||
'1.7.4' => 'V22',
|
||||
'1.8.0' => 'V23'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
61
src/Appwrite/Migration/Version/V23.php
Normal file
61
src/Appwrite/Migration/Version/V23.php
Normal 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']));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue