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

FosuserAddIndexes   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 55
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreDependencies() 0 4 1
A getPostDependencies() 0 4 1
A migrate() 0 22 4
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