Add console

This commit is contained in:
Jake Barnby 2025-05-17 00:19:12 +12:00
parent be400681e7
commit c56dba6b20
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -4,6 +4,7 @@ namespace Appwrite\Platform\Tasks;
use Appwrite\Migration\Migration;
use Redis;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
@ -64,7 +65,7 @@ class Migrate extends Action
$migration = new $class();
$count = 0;
$total = $dbForPlatform->count('projects');
$total = $dbForPlatform->count('projects') + 1;
$dbForPlatform->foreach('projects', function (Document $project) use ($dbForPlatform, $getProjectDB, $register, $migration, &$count, $total) {
/** @var Database $dbForProject */
@ -84,6 +85,18 @@ class Migrate extends Action
Console::log('Migrated ' . ++$count . '/' . $total . ' projects...');
});
$console = (new App('UTC'))->getResource('console');
try {
$migration
->setProject($console, $getProjectDB($console), $dbForPlatform)
->setPDO($register->get('db', true))
->execute();
} catch (\Throwable $th) {
Console::error('Failed to migrate project "console" with error: ' . $th->getMessage());
throw $th;
}
Console::success('Migration completed');
}
}