Completed
Push — master ( 0bfde0...914031 )
by Aimeos
08:19
created

ProductMigratePropertyTypeDomain::migrate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 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
 * Changes default product type and label values.
14
 */
15
class ProductMigratePropertyTypeDomain extends \Aimeos\MW\Setup\Task\Base
16
{
17
	private $mysql = 'UPDATE "mshop_product_property_type" SET "domain" = \'product\' WHERE "code" = \'product/property\'';
18
19
20
	/**
21
	 * Returns the list of task names which this task depends on.
22
	 *
23
	 * @return string[] List of task names
24
	 */
25
	public function getPreDependencies()
26
	{
27
		return [];
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( 'TablesCreateMShop' );
39
	}
40
41
42
	/**
43
	 * Executes the task for MySQL databases.
44
	 */
45
	public function migrate()
46
	{
47
		$this->process( $this->mysql );
48
	}
49
50
51
	/**
52
	 * Executes the task.
53
	 *
54
	 * @param string $stmt SQL statement to execute
55
	 */
56
	protected function process( $stmt )
57
	{
58
		$msg = 'Migrating product property domain to "product"';
59
		$this->msg( $msg, 0 );
60
61
		if( $this->schema->tableExists( 'mshop_product_property_type' ) )
62
		{
63
			$result = $this->conn->create( $stmt )->execute();
64
			$cntRows = $result->affectedRows();
65
			$result->finish();
66
67
			if( $cntRows ) {
68
				$this->status( sprintf( '%1$d/%1$d', $cntRows ) );
69
			} else {
70
				$this->status( 'OK' );
71
			}
72
		}
73
		else
74
		{
75
			$this->status( 'OK' );
76
		}
77
	}
78
79
}