Merge pull request #5356 from appwrite/fix-migration-v18

fix: migration for 1.3.x
This commit is contained in:
Torsten Dittmann 2023-04-12 18:27:20 +02:00 committed by GitHub
commit 7cec672a63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 7 deletions

View file

@ -1356,7 +1356,7 @@ App::get('/v1/account/prefs')
->inject('user')
->action(function (Response $response, Document $user) {
$prefs = $user->getAttribute('prefs', new \stdClass());
$prefs = $user->getAttribute('prefs', []);
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});

View file

@ -223,7 +223,7 @@ App::get('/v1/teams/:teamId/prefs')
throw new Exception(Exception::TEAM_NOT_FOUND);
}
$prefs = $team->getAttribute('prefs', new \stdClass());
$prefs = $team->getAttribute('prefs', []);
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});

View file

@ -457,7 +457,7 @@ App::get('/v1/users/:userId/prefs')
throw new Exception(Exception::USER_NOT_FOUND);
}
$prefs = $user->getAttribute('prefs', new \stdClass());
$prefs = $user->getAttribute('prefs', []);
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
});

View file

@ -33,9 +33,7 @@ class V18 extends Migration
$this->migrateCollections();
Console::info('Migrating Documents');
$this->forEachDocument(function (Document $document) {
$this->migrateDocument($document);
});
$this->forEachDocument([$this, 'fixDocument']);
}
/**
@ -131,7 +129,7 @@ class V18 extends Migration
* @param Document $document
* @return Document
*/
private function migrateDocument(Document $document): Document
protected function fixDocument(Document $document): Document
{
switch ($document->getCollection()) {
case 'projects':