From 7a86109dd900b33a44ac0dcae2ed63d52fe25be7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 2 Jul 2021 11:09:02 +0200 Subject: [PATCH] move versions list to migration class --- app/tasks/migrate.php | 12 ++++-------- src/Appwrite/Migration/Migration.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index 5bd44615e..e6703d925 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -8,20 +8,16 @@ 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\Migration; use Utopia\Validator\Text; $cli ->task('migrate') ->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)) { + if (!array_key_exists($version, Migration::$versions)) { Console::error("Version {$version} not found."); Console::exit(1); return; @@ -52,7 +48,7 @@ $cli $projects = [$console]; $count = 0; - $class = "Appwrite\\Migration\\Version\\$versions[$version]"; + $class = 'Appwrite\\Migration\\Version\\'.Migration::$versions[$version]; $migration = new $class($register->get('db')); while ($sum > 0) { diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index ed18bf85e..0d6995b06 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -31,6 +31,16 @@ abstract class Migration */ protected $projectDB; + /** + * @var array + */ + public static array $versions = [ + '0.6.0' => 'V05', + '0.7.0' => 'V06', + '0.8.0' => 'V07', + '0.9.0' => 'V08', + ]; + /** * Migration constructor. *