Passed
Push — master ( bada6f...d61b94 )
by Aimeos
04:42
created

LocaleRemoveCharConstraints::before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019-2021
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
class LocaleRemoveCharConstraints extends Base
13
{
14
	public function before() : array
15
	{
16
		return ['TablesCreateMShop'];
17
	}
18
19
20
	public function up()
21
	{
22
		$db = $this->db( 'db-locale' );
23
24
		if( !$db->hasTable( 'mshop_locale' ) ) {
25
			return;
26
		}
27
28
		$this->info( 'Remove mshop_locale char constraints' , 'v' );
29
30
		if( $db->hasForeign( 'mshop_locale', 'fk_msloc_langid' )
31
			&& $db->hasColumn( 'mshop_locale', 'langid' )
32
			&& $db->table( 'mshop_locale' )->col( 'langid', 'string' )->fixed()
33
		) {
34
			$this->info( 'Checking constraint for "langid"', 'v', 1 );
35
			$db->dropForeign( 'mshop_locale', 'fk_msloc_langid' );
36
		}
37
38
		if( $db->hasForeign( 'mshop_locale', 'fk_msloc_currid' )
39
			&& $db->hasColumn( 'mshop_locale', 'currencyid' )
40
			&& $db->table( 'mshop_locale' )->col( 'currencyid', 'string' )->fixed()
41
		) {
42
			$this->info( 'Checking constraint for "currencyid"', 'v', 1 );
43
			$db->dropForeign( 'mshop_locale', 'fk_msloc_currid' );
44
		}
45
	}
46
}
47