1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Removes signed constraints from users_* tables before migrating to unsigned |
14
|
|
|
*/ |
15
|
|
|
class UsersRemoveSignedConstraints 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() |
23
|
|
|
{ |
24
|
|
|
return []; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns the list of task names which depends on this task. |
30
|
|
|
* |
31
|
|
|
* @return array List of task names |
32
|
|
|
*/ |
33
|
|
|
public function getPostDependencies() |
34
|
|
|
{ |
35
|
|
|
return ['TablesCreateMShop']; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Executes the task |
41
|
|
|
*/ |
42
|
|
|
public function migrate() |
43
|
|
|
{ |
44
|
|
|
$sql = 'SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = \'users\' AND COLUMN_NAME = \'id\''; |
45
|
|
|
|
46
|
|
|
if( $this->getValue( $sql, 'COLUMN_TYPE', 'db-customer' ) === 'int(10)' ) |
47
|
|
|
{ |
48
|
|
|
$this->msg( sprintf( 'Remove signed constraints in users related tables' ), 0 ); |
49
|
|
|
$this->status( '' ); |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->msg( 'Checking constraint in "users_address"', 1 ); |
53
|
|
|
|
54
|
|
|
if( $schema->constraintExists( 'users_address', 'fk_lvuad_pid' ) ) |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
$this->execute( 'ALTER TABLE "users_address" DROP FOREIGN KEY "fk_lvuad_pid"', 'db-customer' ); |
57
|
|
|
$this->status( 'done' ); |
58
|
|
|
} |
59
|
|
|
else |
60
|
|
|
{ |
61
|
|
|
$this->status( 'OK' ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
$this->msg( 'Checking constraint in "users_list"', 1 ); |
66
|
|
|
|
67
|
|
|
if( $schema->constraintExists( 'users_list', 'fk_lvuli_pid' ) ) |
68
|
|
|
{ |
69
|
|
|
$this->execute( 'ALTER TABLE "users_list" DROP FOREIGN KEY "fk_lvuli_pid"', 'db-customer' ); |
70
|
|
|
$this->status( 'done' ); |
71
|
|
|
} |
72
|
|
|
else |
73
|
|
|
{ |
74
|
|
|
$this->status( 'OK' ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
$this->msg( 'Checking constraint in "users_property"', 1 ); |
79
|
|
|
|
80
|
|
|
if( $schema->constraintExists( 'users_property', 'fk_lvupr_pid' ) ) |
81
|
|
|
{ |
82
|
|
|
$this->execute( 'ALTER TABLE "users_property" DROP FOREIGN KEY "fk_lvupr_pid"', 'db-customer' ); |
83
|
|
|
$this->status( 'done' ); |
84
|
|
|
} |
85
|
|
|
else |
86
|
|
|
{ |
87
|
|
|
$this->status( 'OK' ); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |