diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index dad0847e9..5bd44615e 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -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) { diff --git a/src/Appwrite/Migration/Version/V04.php b/src/Appwrite/Migration/Version/V04.php deleted file mode 100644 index 3b13d8920..000000000 --- a/src/Appwrite/Migration/Version/V04.php +++ /dev/null @@ -1,14 +0,0 @@ -