feat(migration): add version chooser
This commit is contained in:
parent
75ce42ea6e
commit
a6e331390a
|
@ -8,12 +8,26 @@ use Appwrite\Database\Database;
|
|||
use Appwrite\Database\Validator\Authorization;
|
||||
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
||||
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
||||
use Appwrite\Migration\Version;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
$cli
|
||||
->task('migrate')
|
||||
->action(function () use ($register) {
|
||||
Console::success('Starting Data Migration');
|
||||
->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true)
|
||||
->action(function ($version) use ($register) {
|
||||
$versions = [
|
||||
'0.6.0' => 'V05',
|
||||
'0.7.0' => 'V06',
|
||||
'0.8.0' => 'V07',
|
||||
'0.9.0' => 'V08',
|
||||
];
|
||||
|
||||
if (!array_key_exists($version, $versions)) {
|
||||
Console::error("Version {$version} not found.");
|
||||
Console::exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
Console::success('Starting Data Migration to version '.$version);
|
||||
$db = $register->get('db', true);
|
||||
$cache = $register->get('cache', true);
|
||||
|
||||
|
@ -38,7 +52,8 @@ $cli
|
|||
$projects = [$console];
|
||||
$count = 0;
|
||||
|
||||
$migration = new Version\V08($register->get('db')); //TODO: remove hardcoded version and move to dynamic migration
|
||||
$class = "Appwrite\\Migration\\Version\\$versions[$version]";
|
||||
$migration = new $class($register->get('db'));
|
||||
|
||||
while ($sum > 0) {
|
||||
foreach ($projects as $project) {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Migration\Version;
|
||||
|
||||
use Utopia\CLI\Console;
|
||||
use Appwrite\Migration\Migration;
|
||||
|
||||
class V04 extends Migration
|
||||
{
|
||||
public function execute(): void
|
||||
{
|
||||
Console::log('I got nothing to do.');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue