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
|
|
|
* Adds typeid column to list tables and migrates data in type column. |
14
|
|
|
*/ |
15
|
|
|
class IndexRemoveTextMeta extends \Aimeos\MW\Setup\Task\Base |
16
|
|
|
{ |
17
|
|
|
private $indexes = [ |
18
|
|
|
'idx_msindte_value' => 'ALTER TABLE "mshop_index_text" DROP INDEX "idx_msindte_value"', |
19
|
|
|
'unq_msindte_p_s_tid_lt' => 'ALTER TABLE "mshop_index_text" DROP INDEX "unq_msindte_p_s_tid_lt"', |
20
|
|
|
'idx_msindte_p_s_lt_la_ty_do_va' => 'ALTER TABLE "mshop_index_text" DROP INDEX "idx_msindte_p_s_lt_la_ty_do_va"', |
21
|
|
|
]; |
22
|
|
|
private $columns = [ |
23
|
|
|
'textid' => 'ALTER TABLE "mshop_index_text" DROP "textid"', |
24
|
|
|
'listtype' => 'ALTER TABLE "mshop_index_text" DROP "listtype"', |
25
|
|
|
'domain' => 'ALTER TABLE "mshop_index_text" DROP "domain"', |
26
|
|
|
'type' => 'ALTER TABLE "mshop_index_text" DROP "type"', |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Returns the list of task names which this task depends on. |
32
|
|
|
* |
33
|
|
|
* @return string[] List of task names |
34
|
|
|
*/ |
35
|
|
|
public function getPreDependencies() |
36
|
|
|
{ |
37
|
|
|
return ['TablesCreateMShop']; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Returns the list of task names which depends on this task. |
43
|
|
|
* |
44
|
|
|
* @return string[] List of task names |
45
|
|
|
*/ |
46
|
|
|
public function getPostDependencies() |
47
|
|
|
{ |
48
|
|
|
return ['MShopSetLocale']; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Executes the task |
54
|
|
|
*/ |
55
|
|
|
public function migrate() |
56
|
|
|
{ |
57
|
|
|
$this->msg( 'Remove meta columns from mshop_index_text table', 0 ); $this->status( '' ); |
58
|
|
|
$schema = $this->getSchema( 'db-product' ); |
59
|
|
|
|
60
|
|
|
foreach( $this->indexes as $index => $stmt ) |
61
|
|
|
{ |
62
|
|
|
$this->msg( sprintf( 'Checking index "%1$s": ', $index ), 1 ); |
63
|
|
|
|
64
|
|
|
if( $schema->tableExists( 'mshop_index_text' ) === true |
65
|
|
|
&& $schema->indexExists( 'mshop_index_text', $index ) === true ) |
66
|
|
|
{ |
67
|
|
|
$this->execute( $stmt ); |
68
|
|
|
$this->status( 'done' ); |
69
|
|
|
} |
70
|
|
|
else |
71
|
|
|
{ |
72
|
|
|
$this->status( 'OK' ); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
foreach( $this->columns as $column => $stmt ) |
77
|
|
|
{ |
78
|
|
|
$this->msg( sprintf( 'Checking column "%1$s": ', $column ), 1 ); |
79
|
|
|
|
80
|
|
|
if( $schema->tableExists( 'mshop_index_text' ) === true |
81
|
|
|
&& $schema->columnExists( 'mshop_index_text', $column ) === true ) |
82
|
|
|
{ |
83
|
|
|
$this->execute( $stmt ); |
84
|
|
|
$this->status( 'done' ); |
85
|
|
|
} |
86
|
|
|
else |
87
|
|
|
{ |
88
|
|
|
$this->status( 'OK' ); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |