feat: add migration
This commit is contained in:
parent
d48dec3c87
commit
ef65d5a224
2 changed files with 60 additions and 0 deletions
|
@ -54,6 +54,7 @@ abstract class Migration
|
||||||
'1.2.1' => 'V17',
|
'1.2.1' => 'V17',
|
||||||
'1.3.0' => 'V18',
|
'1.3.0' => 'V18',
|
||||||
'1.3.1' => 'V18',
|
'1.3.1' => 'V18',
|
||||||
|
'1.4.0' => 'V19',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
59
src/Appwrite/Migration/Version/V19.php
Normal file
59
src/Appwrite/Migration/Version/V19.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Migration\Version;
|
||||||
|
|
||||||
|
use Appwrite\Migration\Migration;
|
||||||
|
use Utopia\CLI\Console;
|
||||||
|
use Utopia\Database\Database;
|
||||||
|
use Utopia\Database\Document;
|
||||||
|
|
||||||
|
class V19 extends Migration
|
||||||
|
{
|
||||||
|
public function execute(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable SubQueries for Performance.
|
||||||
|
*/
|
||||||
|
foreach (['subQueryIndexes', 'subQueryPlatforms', 'subQueryDomains', 'subQueryKeys', 'subQueryWebhooks', 'subQuerySessions', 'subQueryTokens', 'subQueryMemberships', 'subQueryVariables'] as $name) {
|
||||||
|
Database::addFilter(
|
||||||
|
$name,
|
||||||
|
fn () => null,
|
||||||
|
fn () => []
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console::log('Migrating Project: ' . $this->project->getAttribute('name') . ' (' . $this->project->getId() . ')');
|
||||||
|
$this->projectDB->setNamespace("_{$this->project->getInternalId()}");
|
||||||
|
|
||||||
|
Console::info('Migrating Documents');
|
||||||
|
$this->forEachDocument([$this, 'fixDocument']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix run on each document
|
||||||
|
*
|
||||||
|
* @param Document $document
|
||||||
|
* @return Document
|
||||||
|
*/
|
||||||
|
protected function fixDocument(Document $document): Document
|
||||||
|
{
|
||||||
|
switch ($document->getCollection()) {
|
||||||
|
case 'projects':
|
||||||
|
/**
|
||||||
|
* Bump version number.
|
||||||
|
*/
|
||||||
|
$document->setAttribute('version', '1.4.0');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default disallowPersonalData to false.
|
||||||
|
*/
|
||||||
|
$document->setAttribute('auths', array_merge($document->getAttribute('auths', []), [
|
||||||
|
'disallowPersonalData' => false
|
||||||
|
]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $document;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue