|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Migrate the database schema |
|
14
|
|
|
*/ |
|
15
|
|
|
class FosuserAddIndexes extends \Aimeos\MW\Setup\Task\Base |
|
16
|
|
|
{ |
|
17
|
|
|
private $list = array( |
|
18
|
|
|
'idx_fosus_langid' => 'CREATE INDEX "idx_fosus_langid" ON "fos_user" ("langid")', |
|
19
|
|
|
'idx_fosus_enabled_ln_fn' => 'CREATE INDEX "idx_fosus_status_lastname_firstname" ON "fos_user" ("enabled", "lastname", "firstname")', |
|
20
|
|
|
'idx_fosus_enabled_ad1_ad2' => 'CREATE INDEX "idx_fosus_status_address1_address2" ON "fos_user" ("enabled", "address1", "address2")', |
|
21
|
|
|
'idx_fosus_enabled_postal_city' => 'CREATE INDEX "idx_fosus_status_postal_city" ON "fos_user" ("enabled", "postal", "city")', |
|
22
|
|
|
'idx_fosus_lastname' => 'CREATE INDEX "idx_fosus_lastname" ON "fos_user" ("lastname")', |
|
23
|
|
|
'idx_fosus_address1' => 'CREATE INDEX "idx_fosus_address1" ON "fos_user" ("address1")', |
|
24
|
|
|
'idx_fosus_postal' => 'CREATE INDEX "idx_fosus_postal" ON "fos_user" ("postal")', |
|
25
|
|
|
'idx_fosus_city' => 'CREATE INDEX "idx_fosus_city" ON "fos_user" ("city")', |
|
26
|
|
|
); |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Returns the list of task names which this task depends on. |
|
31
|
|
|
* |
|
32
|
|
|
* @return string[] List of task names |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getPreDependencies() |
|
35
|
|
|
{ |
|
36
|
|
|
return array(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Returns the list of task names which depends on this task. |
|
42
|
|
|
* |
|
43
|
|
|
* @return array List of task names |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getPostDependencies() |
|
46
|
|
|
{ |
|
47
|
|
|
return array( 'TablesCreateFosUser' ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Update database schema |
|
53
|
|
|
*/ |
|
54
|
|
|
public function migrate() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->msg( 'Adding indexes from "fos_user"', 0 ); $this->status( '' ); |
|
57
|
|
|
|
|
58
|
|
|
$schema = $this->getSchema( 'db-customer' ); |
|
59
|
|
|
|
|
60
|
|
|
foreach( $this->list as $idx => $stmt ) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->msg( sprintf( 'Checking index "%1$s"', $idx ), 0 ); |
|
63
|
|
|
|
|
64
|
|
|
if( $schema->tableExists( 'fos_user' ) === true |
|
65
|
|
|
&& $schema->indexExists( 'fos_user', $idx ) === false ) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->execute( $stmt ); |
|
68
|
|
|
$this->status( 'done' ); |
|
69
|
|
|
} |
|
70
|
|
|
else |
|
71
|
|
|
{ |
|
72
|
|
|
$this->status( 'OK' ); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|