move versions list to migration class
This commit is contained in:
parent
a6e331390a
commit
7a86109dd9
|
@ -8,20 +8,16 @@ use Appwrite\Database\Database;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
||||||
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
||||||
|
use Appwrite\Migration\Migration;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
|
|
||||||
$cli
|
$cli
|
||||||
->task('migrate')
|
->task('migrate')
|
||||||
->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true)
|
->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true)
|
||||||
->action(function ($version) use ($register) {
|
->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::error("Version {$version} not found.");
|
||||||
Console::exit(1);
|
Console::exit(1);
|
||||||
return;
|
return;
|
||||||
|
@ -52,7 +48,7 @@ $cli
|
||||||
$projects = [$console];
|
$projects = [$console];
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
$class = "Appwrite\\Migration\\Version\\$versions[$version]";
|
$class = 'Appwrite\\Migration\\Version\\'.Migration::$versions[$version];
|
||||||
$migration = new $class($register->get('db'));
|
$migration = new $class($register->get('db'));
|
||||||
|
|
||||||
while ($sum > 0) {
|
while ($sum > 0) {
|
||||||
|
|
|
@ -31,6 +31,16 @@ abstract class Migration
|
||||||
*/
|
*/
|
||||||
protected $projectDB;
|
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.
|
* Migration constructor.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue