1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Renames the "refid" column to "parentid" |
14
|
|
|
*/ |
15
|
|
|
class CustomerChangeAddressRefidParentidLaravel extends \Aimeos\MW\Setup\Task\Base |
16
|
|
|
{ |
17
|
|
|
private $mysql = array( |
18
|
|
|
'refid' => array( |
19
|
|
|
'ALTER TABLE "users_address" CHANGE "refid" "parentid" INTEGER NOT NULL', |
20
|
|
|
'ALTER TABLE "users_address" DROP INDEX "idx_lvuad_refid", ADD INDEX "idx_lvuad_pid" ("parentid")', |
21
|
|
|
), |
22
|
|
|
); |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Returns the list of task names which depends on this task. |
27
|
|
|
* |
28
|
|
|
* @return string[] List of task names |
29
|
|
|
*/ |
30
|
|
|
public function getPostDependencies() |
31
|
|
|
{ |
32
|
|
|
return ['TablesCreateMShop']; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Migrate database schema |
38
|
|
|
*/ |
39
|
|
|
public function migrate() |
40
|
|
|
{ |
41
|
|
|
$this->process( $this->mysql ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Changes the column in table |
47
|
|
|
* |
48
|
|
|
* array string $stmts List of SQL statements for changing the columns |
49
|
|
|
*/ |
50
|
|
|
protected function process( array $stmts ) |
51
|
|
|
{ |
52
|
|
|
$table = 'users_address'; |
53
|
|
|
$this->msg( sprintf( 'Rename "refid" to "parentid" in table "%1$s"', $table ), 0 ); $this->status( '' ); |
54
|
|
|
|
55
|
|
|
foreach( $stmts as $column => $stmts ) |
56
|
|
|
{ |
57
|
|
|
$this->msg( sprintf( 'Checking column "%1$s"', $column ), 1 ); |
58
|
|
|
|
59
|
|
|
if( $this->schema->tableExists( $table ) |
60
|
|
|
&& $this->schema->columnExists( $table, $column ) === true |
61
|
|
|
) { |
62
|
|
|
$this->executeList( $stmts ); |
63
|
|
|
$this->status( 'done' ); |
64
|
|
|
} else { |
65
|
|
|
$this->status( 'OK' ); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|