Completed
Push — master ( 201bf3...094a7b )
by Aimeos
02:16
created

FosuserAddIndexes::migrate()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 4
nc 3
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2017
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Migrate the database schema
14
 */
15
class FosuserAddIndexes extends \Aimeos\MW\Setup\Task\Base
16
{
17
	private $list = array(
18
		// done by Doctrine schema update
19
	);
20
21
22
	/**
23
	 * Returns the list of task names which this task depends on.
24
	 *
25
	 * @return string[] List of task names
26
	 */
27
	public function getPreDependencies()
28
	{
29
		return [];
30
	}
31
32
33
	/**
34
	 * Returns the list of task names which depends on this task.
35
	 *
36
	 * @return array List of task names
37
	 */
38
	public function getPostDependencies()
39
	{
40
		return array( 'TablesCreateFosUser' );
41
	}
42
43
44
	/**
45
	 * Update database schema
46
	 */
47
	public function migrate()
48
	{
49
		$this->msg( 'Adding indexes from "fos_user"', 0 ); $this->status( '' );
50
51
		$schema = $this->getSchema( 'db-customer' );
52
53
		foreach( $this->list as $idx => $stmt )
54
		{
55
			$this->msg( sprintf( 'Checking index "%1$s"', $idx ), 0 );
56
57
			if( $schema->tableExists( 'fos_user' ) === true
58
				&& $schema->indexExists( 'fos_user', $idx ) === false )
59
			{
60
				$this->execute( $stmt );
61
				$this->status( 'done' );
62
			}
63
			else
64
			{
65
				$this->status( 'OK' );
66
			}
67
		}
68
	}
69
}
70