Passed
Push — master ( 7130a8...b35ffc )
by Aimeos
05:11
created

OrderRenameTables::tables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 12
rs 9.9666
cc 1
nc 1
nop 0
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
		$this->db( 'db-order' )
34
			->dropForeign( 'mshop_order_base_product_attr', 'fk_msordbaprat_parentid' )
35
			->dropForeign( 'mshop_order_base_service_attr', 'fk_msordbaseat_parentid' )
36
			->dropForeign( 'mshop_order_base_service_tx', 'fk_msordbasetx_parentid' );
37
38
		return $this;
39
	}
40
41
42
	protected function indexes()
43
	{
44
		$this->db( 'db-order' )
45
			->dropIndex( 'mshop_order_base_product_attr', 'unq_msordbaprat_oid_aid_ty_cd' )
46
			->dropIndex( 'mshop_order_base_product_attr', 'idx_msordbaprat_si_cd_va' )
47
			->dropIndex( 'mshop_order_base_service_attr', 'unq_msordbaseat_oid_aid_ty_cd' )
48
			->dropIndex( 'mshop_order_base_service_attr', 'idx_msordbaseat_si_cd_va' );
49
50
		return $this;
51
	}
52
53
54
	protected function tables()
55
	{
56
		$this->db( 'db-order' )
57
			->renameTable( 'mshop_order_base_address', 'mshop_order_address' )
58
			->renameTable( 'mshop_order_base_coupon', 'mshop_order_coupon' )
59
			->renameTable( 'mshop_order_base_product', 'mshop_order_product' )
60
			->renameTable( 'mshop_order_base_product_attr', 'mshop_order_product_attr' )
61
			->renameTable( 'mshop_order_base_service', 'mshop_order_service' )
62
			->renameTable( 'mshop_order_base_service_attr', 'mshop_order_service_attr' )
63
			->renameTable( 'mshop_order_base_service_tx', 'mshop_order_service_tx' );
64
65
		return $this;
66
	}
67
}
68