Completed
Push — master ( fb0f3e...c64f58 )
by Aimeos
12:31
created

StockAddTypeDomainValue::migrate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 15
rs 9.4285
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Adds the domain value
14
 */
15
class StockAddTypeDomainValue extends \Aimeos\MW\Setup\Task\Base
16
{
17
	private $sql = 'UPDATE "mshop_stock_type" SET "domain"=\'product\' WHERE "domain"=\'\'';
18
19
20
	/**
21
	 * Returns the list of task names which this task depends on.
22
	 *
23
	 * @return array List of task names
24
	 */
25
	public function getPreDependencies()
26
	{
27
		return array( 'TablesCreateMShop' );
28
	}
29
30
31
	/**
32
	 * Returns the list of task names which depends on this task.
33
	 *
34
	 * @return string[] List of task names
35
	 */
36
	public function getPostDependencies()
37
	{
38
		return array();
39
	}
40
41
42
	/**
43
	 * Cleans up the tables
44
	 */
45
	public function clean()
46
	{
47
		$this->migrate();
48
	}
49
50
51
	/**
52
	 * Migrate the tables
53
	 */
54
	public function migrate()
55
	{
56
		$this->msg( 'Add stock type domain values', 0 ); $this->status( '' );
57
		$schema = $this->getSchema( 'db-product' );
58
59
		if( $schema->tableExists( 'mshop_stock_type' ) )
60
		{
61
			$this->execute( $this->sql );
62
			$this->status( 'done' );
63
		}
64
		else
65
		{
66
			$this->status( 'OK' );
67
		}
68
	}
69
}
70