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. *