1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Removes meta data from index price table |
14
|
|
|
*/ |
15
|
|
|
class IndexRemovePriceMeta extends \Aimeos\MW\Setup\Task\Base |
16
|
|
|
{ |
17
|
|
|
private $clear = 'DELETE FROM "mshop_index_price"'; |
18
|
|
|
private $indexes = [ |
19
|
|
|
'unq_msindpr_p_s_prid_lt' => 'ALTER TABLE "mshop_index_price" DROP INDEX "unq_msindpr_p_s_prid_lt"', |
20
|
|
|
'idx_msindpr_s_lt_cu_ty_va' => 'ALTER TABLE "mshop_index_price" DROP INDEX "idx_msindpr_s_lt_cu_ty_va"', |
21
|
|
|
'idx_msindpr_p_s_lt_cu_ty_va' => 'ALTER TABLE "mshop_index_price" DROP INDEX "idx_msindpr_p_s_lt_cu_ty_va"', |
22
|
|
|
]; |
23
|
|
|
private $columns = [ |
24
|
|
|
'priceid' => 'ALTER TABLE "mshop_index_price" DROP "priceid"', |
25
|
|
|
'listtype' => 'ALTER TABLE "mshop_index_price" DROP "listtype"', |
26
|
|
|
'type' => 'ALTER TABLE "mshop_index_price" DROP "type"', |
27
|
|
|
'costs' => 'ALTER TABLE "mshop_index_price" DROP "costs"', |
28
|
|
|
'rebate' => 'ALTER TABLE "mshop_index_price" DROP "rebate"', |
29
|
|
|
'taxrate' => 'ALTER TABLE "mshop_index_price" DROP "taxrate"', |
30
|
|
|
'quantity' => 'ALTER TABLE "mshop_index_price" DROP "quantity"', |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Returns the list of task names which this task depends on. |
36
|
|
|
* |
37
|
|
|
* @return string[] List of task names |
38
|
|
|
*/ |
39
|
|
|
public function getPreDependencies() |
40
|
|
|
{ |
41
|
|
|
return []; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the list of task names which depends on this task. |
47
|
|
|
* |
48
|
|
|
* @return string[] List of task names |
49
|
|
|
*/ |
50
|
|
|
public function getPostDependencies() |
51
|
|
|
{ |
52
|
|
|
return ['TablesCreateMShop']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Executes the task |
58
|
|
|
*/ |
59
|
|
|
public function migrate() |
60
|
|
|
{ |
61
|
|
|
$this->msg( 'Remove meta columns from mshop_index_price table', 0 ); $this->status( '' ); |
62
|
|
|
$schema = $this->getSchema( 'db-product' ); |
63
|
|
|
|
64
|
|
|
foreach( $this->indexes as $index => $stmt ) |
65
|
|
|
{ |
66
|
|
|
$this->msg( sprintf( 'Checking index "%1$s": ', $index ), 1 ); |
67
|
|
|
|
68
|
|
|
if( $schema->tableExists( 'mshop_index_price' ) === true |
69
|
|
|
&& $schema->indexExists( 'mshop_index_price', $index ) === true ) |
70
|
|
|
{ |
71
|
|
|
$this->execute( $this->clear ); |
72
|
|
|
$this->execute( $stmt ); |
73
|
|
|
$this->status( 'done' ); |
74
|
|
|
} |
75
|
|
|
else |
76
|
|
|
{ |
77
|
|
|
$this->status( 'OK' ); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
foreach( $this->columns as $column => $stmt ) |
82
|
|
|
{ |
83
|
|
|
$this->msg( sprintf( 'Checking column "%1$s": ', $column ), 1 ); |
84
|
|
|
|
85
|
|
|
if( $schema->tableExists( 'mshop_index_price' ) === true |
86
|
|
|
&& $schema->columnExists( 'mshop_index_price', $column ) === true ) |
87
|
|
|
{ |
88
|
|
|
$this->execute( $stmt ); |
89
|
|
|
$this->status( 'done' ); |
90
|
|
|
} |
91
|
|
|
else |
92
|
|
|
{ |
93
|
|
|
$this->status( 'OK' ); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
} |