FEUsersMigrateCountryTypo3   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 27
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 3 1
A up() 0 11 3
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Migrates country column values in fe_users table.
14
 */
15
class FEUsersMigrateCountryTypo3 extends Base
16
{
17
	/**
18
	 * Returns the list of task names which depends on this task.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function before() : array
23
	{
24
		return ['Customer'];
25
	}
26
27
28
	/**
29
	 * Migrates country column values in fe_users table.
30
	 */
31
	public function up()
32
	{
33
		$db = $this->db( 'db-customer' );
34
35
		if( !$db->hasTable( ['fe_users', 'static_countries'] ) || !$db->hasColumn( 'fe_users', 'static_info_country' ) ) {
36
			return;
37
		}
38
39
		$this->info( 'Migrating "static_info_country" column in "fe_users" table', 'vv' );
40
41
		$db->exec( '
42
			UPDATE fe_users SET static_info_country = (
43
				SELECT cn_iso_2 FROM static_countries WHERE cn_iso_3 = static_info_country
44
			) WHERE LENGTH(static_info_country) = 3
45
		' );
46
	}
47
}