Passed
Push — master ( adcf3e...b46687 )
by Aimeos
05:09
created

LocaleRemoveCharConstraints   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 3 1
A up() 0 18 5
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 ['Locale'];
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
36
			$db->dropForeign( 'mshop_locale', 'fk_msloc_langid' );
37
			$db->dropIndex( 'mshop_locale', 'fk_msloc_langid' );
38
		}
39
	}
40
}
41