Passed
Push — master ( c9773b...29143b )
by Aimeos
05:44
created

CouponMigrateBasetValues::getPreDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019-2021
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Migrates the BasketValues decorator in coupon table
14
 */
15
class CouponMigrateBasetValues extends \Aimeos\MW\Setup\Task\Base
16
{
17
	/**
18
	 * Returns the list of task names which this task depends on.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function getPreDependencies() : array
23
	{
24
		return ['TablesCreateMShop'];
25
	}
26
27
28
	/**
29
	 * Migrate database schema
30
	 */
31
	public function migrate()
32
	{
33
		$dbdomain = 'db-coupon';
34
		$this->msg( 'Migrating basketvalues configuration in coupon table', 0 );
35
36
		if( $this->getSchema( $dbdomain )->tableExists( 'mshop_coupon' ) === false )
37
		{
38
			$this->status( 'OK' );
39
			return;
40
		}
41
42
		$update = '
43
			UPDATE "mshop_coupon"
44
			SET "provider" = REPLACE("provider", \'BasketValues\', \'Basket\'),
45
				"config" = REPLACE("config", \'basketvalues\', \'basket\')
46
			WHERE "provider" LIKE \'%BasketValues%\' OR "config" LIKE \'%basketvalues%\'
47
		';
48
49
		$conn = $this->acquire( $dbdomain );
50
		$conn->create( $update )->execute();
51
		$this->release( $conn, $dbdomain );
52
53
		$this->status( 'done' );
54
	}
55
}
56