Passed
Pull Request — master (#182)
by Simon
04:41
created

getPreDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019
6
 */
7
8
9
namespace Aimeos\MW\Setup\Task;
10
11
12
/**
13
 * Remove incompatible index tables.
14
 */
15
class IndexRemoveIncompatibleTables extends \Aimeos\MW\Setup\Task\Base
16
{
17
	/**
18
	 * Returns the list of task names which this task depends on.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function getPreDependencies()
23
	{
24
		return [];
25
	}
26
27
28
	/**
29
	 * Returns the list of task names which depends on this task.
30
	 *
31
	 * @return string[] List of task names
32
	 */
33
	public function getPostDependencies()
34
	{
35
		return ['TablesCreateMShop', 'IndexRebuild'];
36
	}
37
38
39
	/**
40
	 * Executes the task
41
	 */
42
	public function migrate()
43
	{
44
		$this->msg('Remove incompatible index tables', 0);
45
		$this->status('');
46
47
		$schema = $this->getSchema('db-product');
48
49
		$table = 'mshop_index_text';
50
		$this->msg(sprintf('Checking table "%1$s"', $table), 1);
51
52
		if ( $schema->tableExists($table) === true
53
			&& $schema->columnExists($table, 'url') === false ) {
54
			$this->execute('DROP TABLE "mshop_index_text"');
55
			IndexRebuild::forceExecute();
56
57
			$this->status('done');
58
		} else {
59
			$this->status('OK');
60
		}
61
	}
62
}
63