|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2021 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Upscheme\Task; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class OrderRenameAttributeParentid extends Base |
|
13
|
|
|
{ |
|
14
|
|
|
public function before() : array |
|
15
|
|
|
{ |
|
16
|
|
|
return ['Order']; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
public function up() |
|
21
|
|
|
{ |
|
22
|
|
|
$db = $this->db( 'db-order' ); |
|
23
|
|
|
|
|
24
|
|
|
if( !$db->hasTable( 'mshop_order_base_product_attr' ) && !$db->hasTable( 'mshop_order_base_service_attr' ) ) { |
|
25
|
|
|
return; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
if( $db->hasTable( 'mshop_order_base_product_attr' ) |
|
29
|
|
|
&& !$db->hasColumn( 'mshop_order_base_product_attr', 'parentid' ) |
|
30
|
|
|
) { |
|
31
|
|
|
$this->info( 'Rename "ordprodid" to "parentid" in "mshop_order_base_product_attr" table', 'v' ); |
|
32
|
|
|
|
|
33
|
|
|
$db->dropForeign( 'mshop_order_base_product_attr', 'fk_msordbaprat_ordprodid' ) |
|
34
|
|
|
->dropIndex( 'mshop_order_base_product_attr', 'fk_msordbaprat_ordprodid' ) |
|
35
|
|
|
->dropIndex( 'mshop_order_base_product_attr', 'unq_msordbaprat_oid_aid_ty_cd' ) |
|
36
|
|
|
->renameColumn( 'mshop_order_base_product_attr', 'ordprodid', 'parentid' ); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
if( $db->hasTable( 'mshop_order_base_service_attr' ) |
|
41
|
|
|
&& !$db->hasColumn( 'mshop_order_base_service_attr', 'parentid' ) |
|
42
|
|
|
) { |
|
43
|
|
|
$this->info( 'Rename "ordservid" to "parentid" in "mshop_order_base_service_attr" table', 'v' ); |
|
44
|
|
|
|
|
45
|
|
|
$db->dropForeign( 'mshop_order_base_service_attr', 'fk_msordbaseat_ordservid' ) |
|
46
|
|
|
->dropIndex( 'mshop_order_base_service_attr', 'fk_msordbaseat_ordservid' ) |
|
47
|
|
|
->dropIndex( 'mshop_order_base_service_attr', 'unq_msordbaseat_oid_aid_ty_cd' ) |
|
48
|
|
|
->renameColumn( 'mshop_order_base_service_attr', 'ordservid', 'parentid' ); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|