Passed
Push — master ( abff8d...3429a9 )
by Aimeos
06:12
created

OrderRenameAttributeParentid::before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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
25
		if( $db->hasTable( 'mshop_order_base_product_attr' )
26
			&& !$db->hasColumn( 'mshop_order_base_product_attr', 'parentid' )
27
		) {
28
			$this->info( 'Rename "ordprodid" to "parentid" in "mshop_order_base_product_attr" table', 'v' );
29
30
			$db->dropForeign( 'mshop_order_base_product_attr', 'fk_msordbaprat_ordprodid' )
31
				->dropIndex( 'mshop_order_base_product_attr', 'fk_msordbaprat_ordprodid' )
32
				->dropIndex( 'mshop_order_base_product_attr', 'unq_msordbaprat_oid_aid_ty_cd' )
33
				->renameColumn( 'mshop_order_base_product_attr', 'ordprodid', 'parentid' );
34
		}
35
36
37
		if( $db->hasTable( 'mshop_order_base_service_attr' )
38
			&& !$db->hasColumn( 'mshop_order_base_service_attr', 'parentid' )
39
		) {
40
			$this->info( 'Rename "ordservid" to "parentid" in "mshop_order_base_service_attr" table', 'v' );
41
42
			$db->dropForeign( 'mshop_order_base_service_attr', 'fk_msordbaseat_ordservid' )
43
				->dropIndex( 'mshop_order_base_service_attr', 'fk_msordbaseat_ordservid' )
44
				->dropIndex( 'mshop_order_base_service_attr', 'unq_msordbaseat_oid_aid_ty_cd' )
45
				->renameColumn( 'mshop_order_base_service_attr', 'ordservid', 'parentid' );
46
		}
47
	}
48
}
49