Passed
Push — master ( c52784...833dd8 )
by Aimeos
28:15 queued 16:05
created

TablesMigrateSiteidFosuser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 3 1
A up() 0 16 4
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019-2023
6
 */
7
8
9
 namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Updates site ID columns
14
 */
15
class TablesMigrateSiteidFosuser extends TablesMigrateSiteid
16
{
17
	private $resources = [
18
		'db-customer' => [
19
			'fosuser_list_type', 'fosuser_property_type',
20
			'fosuser_property', 'fosuser_list', 'fosuser_address', 'fosuser',
21
		],
22
	];
23
24
25
	/**
26
	 * Returns the list of task names which this task depends on.
27
	 *
28
	 * @return string[] List of task names
29
	 */
30
	public function before() : array
31
	{
32
		return ['Customer', 'TablesMigrateSiteid'];
33
	}
34
35
36
	/**
37
	 * Executes the task
38
	 */
39
	public function up()
40
	{
41
		$db = $this->db( 'db-locale' );
42
43
		if( !$db->hasTable( 'mshop_locale_site' ) || $db->hasColumn( 'mshop_locale_site', 'siteid' ) ) {
44
			return;
45
		}
46
47
		$this->info( 'Update FosUser "siteid" columns', 'vv' );
48
49
		$this->process( $this->resources );
50
51
		$db = $this->db( 'db-customer' );
52
53
		if( $db->hasColumn( 'users', 'siteid' ) ) {
54
			$db->exec( 'UPDATE users SET siteid=\'\' WHERE siteid IS NULL' );
55
		}
56
	}
57
}
58