forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMigrateVersion.php
More file actions
63 lines (52 loc) · 1.32 KB
/
Copy pathMigrateVersion.php
File metadata and controls
63 lines (52 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php namespace CodeIgniter\Commands\Database;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use Config\Services;
/**
* Migrates the DB to a specific version.
*
* @package CodeIgniter\Commands
*/
class MigrateVersion extends BaseCommand
{
protected $group = 'Database';
/**
* The Command's name
*
* @var string
*/
protected $name = 'migrate:version';
/**
* the Command's short description
*
* @var string
*/
protected $description = 'Migrates the database up or down to get to the specified version.';
/**
* Migrates the database up or down to get to the specified version.
*/
public function run(array $params=[])
{
$runner = Services::migrations();
// Get the version number
$version = array_shift($params);
if (is_null($version))
{
$version = CLI::prompt(lang('Migrations.version'));
}
if (is_null($version))
{
CLI::error(lang('Migrations.invalidVersion'));
exit();
}
CLI::write(sprintf(lang('Migrations.migToVersionPH'), $version), 'yellow');
try {
$runner->version($version);
}
catch (\Exception $e)
{
$this->showError($e);
}
CLI::write('Done');
}
}