Completed
Push — master ( 384616...e3d84b )
by Aimeos
03:42
created

getPostDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Removes address and list records without users entry
14
 */
15
class CustomerRemoveLostUserDataLaravel extends \Aimeos\MW\Setup\Task\Base
16
{
17
	private $sql = [
18
		'address' => 'DELETE FROM "users_address" WHERE NOT EXISTS ( SELECT "id" FROM "users" AS u WHERE "parentid"=u."id" )',
19
		'list' => 'DELETE FROM "users_list" WHERE NOT EXISTS ( SELECT "id" FROM "users" AS u WHERE "parentid"=u."id" )',
20
	];
21
22
23
	/**
24
	 * Returns the list of task names which this task depends on.
25
	 *
26
	 * @return array List of task names
27
	 */
28
	public function getPreDependencies()
29
	{
30
		return [];
31
	}
32
33
34
	/**
35
	 * Returns the list of task names which depends on this task.
36
	 *
37
	 * @return string[] List of task names
38
	 */
39
	public function getPostDependencies()
40
	{
41
		return array( 'TablesCreateMShop' );
42
	}
43
44
45
	/**
46
	 * Migrate database schema
47
	 */
48
	public function migrate()
49
	{
50
		$this->msg( 'Remove left over Laravel user address records', 0 );
51
52 View Code Duplication
		if( $this->schema->tableExists( 'users' ) && $this->schema->tableExists( 'users_address' ) )
0 ignored issues
show
Deprecated Code introduced by
The property Aimeos\MW\Setup\Task\Base::$schema has been deprecated with message: Use getSchema() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
		{
54
			$this->execute( $this->sql['address'] );
55
			$this->status( 'done' );
56
		}
57
		else
58
		{
59
			$this->status( 'OK' );
60
		}
61
62
63
		$this->msg( 'Remove left over Laravel user list records', 0 );
64
65 View Code Duplication
		if( $this->schema->tableExists( 'users' ) && $this->schema->tableExists( 'users_list' ) )
0 ignored issues
show
Deprecated Code introduced by
The property Aimeos\MW\Setup\Task\Base::$schema has been deprecated with message: Use getSchema() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
		{
67
			$this->execute( $this->sql['list'] );
68
			$this->status( 'done' );
69
		}
70
		else
71
		{
72
			$this->status( 'OK' );
73
		}
74
	}
75
}
76