diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 4a79ffafbf..f42b601213 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -54,6 +54,7 @@ abstract class Migration '1.2.1' => 'V17', '1.3.0' => 'V18', '1.3.1' => 'V18', + '1.4.0' => 'V19', ]; /** diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php new file mode 100644 index 0000000000..faccdd3524 --- /dev/null +++ b/src/Appwrite/Migration/Version/V19.php @@ -0,0 +1,59 @@ + 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; + } +}