1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2022 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Upscheme\Task; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class OrderRenameTables extends Base |
13
|
|
|
{ |
14
|
|
|
public function before() : array |
15
|
|
|
{ |
16
|
|
|
return [ |
17
|
|
|
'OrderAddProductParentid', 'OrderAddBaseServiceCurrencyid', 'OrderAddBaseProductCurrencyid', |
18
|
|
|
'OrderRenameAttributeParentid', 'OrderRenameProductStatus', 'OrderRenameProductSupplier' |
19
|
|
|
]; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
public function up() |
24
|
|
|
{ |
25
|
|
|
$this->info( 'Rename mshop_order_order_base_* tables', 'vv' ); |
26
|
|
|
|
27
|
|
|
$this->constraints()->indexes()->tables(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
protected function constraints() |
32
|
|
|
{ |
33
|
|
|
$db = $this->db( 'db-order' ); |
34
|
|
|
|
35
|
|
|
if( $db->hasForeign( 'mshop_order_base_product_attr', 'fk_msordbaprat_parentid' ) ) { |
36
|
|
|
$db->dropForeign( 'mshop_order_base_product_attr', 'fk_msordbaprat_parentid' ); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if( $db->hasForeign( 'mshop_order_base_service_attr', 'fk_msordbaseat_parentid' ) ) { |
40
|
|
|
$db->dropForeign( 'mshop_order_base_service_attr', 'fk_msordbaseat_parentid' ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
if( $db->hasForeign( 'mshop_order_base_service_tx', 'fk_msordbasetx_parentid' ) ) { |
44
|
|
|
$db->dropForeign( 'mshop_order_base_service_tx', 'fk_msordbasetx_parentid' ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
protected function indexes() |
52
|
|
|
{ |
53
|
|
|
$db = $this->db( 'db-order' ); |
54
|
|
|
|
55
|
|
|
if( $db->hasIndex( 'mshop_order_base_product_attr', 'unq_msordbaprat_oid_aid_ty_cd' ) ) { |
56
|
|
|
$db->dropIndex( 'mshop_order_base_product_attr', 'unq_msordbaprat_oid_aid_ty_cd' ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if( $db->hasIndex( 'mshop_order_base_product_attr', 'idx_msordbaprat_si_cd_va' ) ) { |
60
|
|
|
$db->dropIndex( 'mshop_order_base_product_attr', 'idx_msordbaprat_si_cd_va' ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if( $db->hasIndex( 'mshop_order_base_service_attr', 'unq_msordbaseat_oid_aid_ty_cd' ) ) { |
64
|
|
|
$db->dropIndex( 'mshop_order_base_service_attr', 'unq_msordbaseat_oid_aid_ty_cd' ); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if( $db->hasIndex( 'mshop_order_base_service_attr', 'idx_msordbaseat_si_cd_va' ) ) { |
68
|
|
|
$db->dropIndex( 'mshop_order_base_service_attr', 'idx_msordbaseat_si_cd_va' ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
protected function tables() |
76
|
|
|
{ |
77
|
|
|
$db = $this->db( 'db-order' ); |
78
|
|
|
|
79
|
|
|
if( $db->hasTable( 'mshop_order_base_address' ) ) { |
80
|
|
|
$db->renameTable( 'mshop_order_base_address', 'mshop_order_address' ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
if( $db->hasTable( 'mshop_order_base_coupon' ) ) { |
84
|
|
|
$db->renameTable( 'mshop_order_base_coupon', 'mshop_order_coupon' ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
if( $db->hasTable( 'mshop_order_base_product' ) ) { |
88
|
|
|
$db->renameTable( 'mshop_order_base_product', 'mshop_order_product' ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
if( $db->hasTable( 'mshop_order_base_product_attr' ) ) { |
92
|
|
|
$db->renameTable( 'mshop_order_base_product_attr', 'mshop_order_product_attr' ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
if( $db->hasTable( 'mshop_order_base_service' ) ) { |
96
|
|
|
$db->renameTable( 'mshop_order_base_service', 'mshop_order_service' ); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
if( $db->hasTable( 'mshop_order_base_service_attr' ) ) { |
100
|
|
|
$db->renameTable( 'mshop_order_base_service_attr', 'mshop_order_service_attr' ); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
if( $db->hasTable( 'mshop_order_base_service_tx' ) ) { |
104
|
|
|
$db->renameTable( 'mshop_order_base_service_tx', 'mshop_order_service_tx' ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|