Minion_Migration::all_migrations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
3
abstract class Minion_Migration extends Minion_Task {
4
5
	protected $_options = array(
6
		'version' => NULL,
7
		'steps' => NULL,
8
		'dry-run' => FALSE
9
	);
10
11
	protected $_migrations;
12
13
	public function migrations()
14
	{
15
		if ( ! $this->_migrations)
16
		{
17
			$this->_migrations = new Migrations(array('log' => 'Minion_CLI::write'));
18
		}
19
20
		return $this->_migrations;
21
	}
22
23
	public function executed_migrations()
24
	{
25
		return array_reverse($this->migrations()->get_executed_migrations());
26
	}
27
28
	public function unexecuted_migrations()
29
	{
30
		return $this->migrations()->get_unexecuted_migrations();
31
	}
32
33
	public function all_migrations()
34
	{
35
		return $this->migrations()->get_migrations();
36
	}
37
38
	public function migrate(array $up, array $down, $dry_run = FALSE)
39
	{
40
		$this->migrations()->execute_all($up, $down, $dry_run);
41
42
		if ($up OR $down)
43
		{
44
			Minion_Task::factory(array('task' => 'db:structure:dump', 'file' => NULL))->execute();
45
		}
46
	}
47
48
	public function build_validation(Validation $validation)
49
	{
50
		return parent::build_validation($validation)
51
			->rule('version', 'exact_length', array(':value', 10))
52
			->rule('version', 'digit')
53
			->rule('steps', 'digit');
54
	}
55
}
56