1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

fix: migration for leftover documents on deleted projects

This commit is contained in:
Torsten Dittmann 2022-01-05 12:49:53 +01:00
parent 8d419491d5
commit 94d49f9685

View file

@ -194,7 +194,7 @@ class V11 extends Migration
$new = $this->fixDocument($document);
if (empty($new->getId())) {
if (is_null($new) || empty($new->getId())) {
Console::warning('Skipped Document due to missing ID.');
continue;
}
@ -496,6 +496,10 @@ class V11 extends Migration
case OldDatabase::SYSTEM_COLLECTION_PLATFORMS:
$projectId = $this->getProjectIdFromReadPermissions($document);
if (is_null($projectId)) {
return null;
}
/**
* Set Project ID
*/
@ -533,6 +537,10 @@ class V11 extends Migration
case OldDatabase::SYSTEM_COLLECTION_DOMAINS:
$projectId = $this->getProjectIdFromReadPermissions($document);
if (is_null($projectId)) {
return null;
}
/**
* Set Project ID
*/
@ -557,6 +565,10 @@ class V11 extends Migration
case OldDatabase::SYSTEM_COLLECTION_KEYS:
$projectId = $this->getProjectIdFromReadPermissions($document);
if (is_null($projectId)) {
return null;
}
/**
* Set Project ID
*/
@ -585,6 +597,10 @@ class V11 extends Migration
case OldDatabase::SYSTEM_COLLECTION_WEBHOOKS:
$projectId = $this->getProjectIdFromReadPermissions($document);
if (is_null($projectId)) {
return null;
}
/**
* Set Project ID
*/
@ -780,7 +796,7 @@ class V11 extends Migration
}
/**
* @param Document $document
* @param Document $document
* @return string|null
* @throws Exception
*/
@ -788,11 +804,17 @@ class V11 extends Migration
{
$readPermissions = $document->getRead();
$teamId = str_replace('team:', '', reset($readPermissions));
return $this->oldConsoleDB->getCollectionFirst([
$project = $this->oldConsoleDB->getCollectionFirst([
'filters' => [
'$collection=' . OldDatabase::SYSTEM_COLLECTION_PROJECTS,
'teamId=' . $teamId
]
])->getId();
]);
if (!$project) {
return null;
}
return $project->getId();
}
}