1
0
Fork 0
mirror of synced 2024-09-20 03:17:30 +12:00

fix: Moving migration to be inside coroutine completely

This commit is contained in:
Binyamin Yawitz 2024-08-08 09:25:56 -04:00
parent 8f0294f9cb
commit 8e7cc6ed14
No known key found for this signature in database
3 changed files with 48 additions and 50 deletions

View file

@ -171,7 +171,6 @@ abstract class Migration
Console::log('Migrating Collection ' . $collection['$id'] . ':');
\Co\run(function (array $collection, callable $callback) {
foreach ($this->documentsIterator($collection['$id']) as $document) {
go(function (Document $document, callable $callback) {
if (empty($document->getId()) || empty($document->getCollection())) {
@ -193,7 +192,6 @@ abstract class Migration
}
}, $document, $callback);
}
}, $collection, $callback);
}
}

View file

@ -816,7 +816,6 @@ class V19 extends Migration
Console::log('Migrating Collection ' . $collection['$id'] . ':');
\Co\run(function (array $collection, callable $callback) {
foreach ($this->documentsIterator($collection['$id']) as $document) {
go(function (Document $document, callable $callback) {
if (empty($document->getId()) || empty($document->getCollection())) {
@ -838,7 +837,6 @@ class V19 extends Migration
}
}, $document, $callback);
}
}, $collection, $callback);
}
}
}

View file

@ -33,8 +33,11 @@ class Migrate extends Action
->inject('dbForConsole')
->inject('getProjectDB')
->inject('register')
->callback(fn ($version, $dbForConsole, $getProjectDB, Registry $register) => $this->action($version, $dbForConsole, $getProjectDB, $register));
->callback(function ($version, $dbForConsole, $getProjectDB, Registry $register) {
\Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register) {
$this->action($version, $dbForConsole, $getProjectDB, $register);
});
});
}
private function clearProjectsCache(Document $project)
@ -50,7 +53,6 @@ class Migrate extends Action
}
}
} while ($iterator > 0);
} catch (\Throwable $th) {
Console::error('Failed to clear project ("' . $project->getId() . '") cache with error: ' . $th->getMessage());
}