Task_DB_Structure_Copy::_execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 11
nop 1
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
3
/**
4
 * Copy the structure of one database to another.
5
 * Will ask for confirmation before proceeding.
6
 *
7
 * options:
8
 * 	- from: database id from config/database.php file to load structure from, 'default' by default
9
 * 	- to: database id from config/database.php file to dump structure to
10
 * 	- force: se this flag to skip confirmation
11
 */
12
class Task_DB_Structure_Copy extends Minion_Database {
13
14
	protected $_options = array(
15
		'from' => 'default',
16
		'to' => NULL,
17
		'force' => FALSE,
18
	);
19
20
	public function build_validation(Validation $validation)
21
	{
22
		return parent::build_validation($validation)
23
			->rule('to', 'not_empty');
24
	}
25
26
	protected function _execute(array $options)
27
	{
28
		Minion_Task::factory(array(
29
				'task' => 'db:structure:dump',
30
				'database' => $options['from'],
31
				'force' => $options['force']
32
			))
33
			->execute();
34
35
		Minion_Task::factory(array(
36
				'task' => 'db:structure:load',
37
				'database' => $options['to'],
38
				'force' => $options['force']
39
			))
40
			->execute();
41
	}
42
}
43