CustomerRemoveConstraints   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 3 1
A up() 0 13 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
 * Removes constraints from users_* tables before migrating to bigint (Laravel 8)
14
 */
15
class CustomerRemoveConstraints extends Base
16
{
17
	/**
18
	 * Returns the list of task names which depends on this task.
19
	 *
20
	 * @return array List of task names
21
	 */
22
	public function before() : array
23
	{
24
		return ['Customer'];
25
	}
26
27
28
	/**
29
	 * Executes the task
30
	 */
31
	public function up()
32
	{
33
		$db = $this->db( 'db-customer' );
34
35
		if( !$db->hasColumn( 'users', 'id' ) || $db->table( 'users' )->col( 'id' )->type() === 'bigint' ) {
36
			return;
37
		}
38
39
		$this->info( sprintf( 'Remove constraints in users related tables' ), 'vv' );
40
41
		$db->dropForeign( 'users_address', 'fk_lvuad_pid' );
42
		$db->dropForeign( 'users_property', 'fk_lvupr_pid' );
43
		$db->dropForeign( 'users_list', 'fk_lvuli_pid' );
44
	}
45
}
46