Passed
Push — master ( f68345...02e211 )
by Aimeos
04:32
created

Index::after()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2024
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
class Index extends Base
13
{
14
	public function before() : array
15
	{
16
		return ['Locale'];
17
	}
18
19
20
	public function after() : array
21
	{
22
		return ['Product'];
23
	}
24
25
26
	public function up()
27
	{
28
		$this->info( 'Creating index schema', 'vv' );
29
		$db = $this->db( 'db-product' );
30
31
		foreach( $this->paths( 'default/schema/index.php' ) as $filepath )
32
		{
33
			if( ( $list = include( $filepath ) ) === false ) {
34
				throw new \RuntimeException( sprintf( 'Unable to get schema from file "%1$s"', $filepath ) );
35
			}
36
37
			foreach( $list['table'] ?? [] as $name => $fcn ) {
38
				$db->table( $name, $fcn );
39
			}
40
		}
41
42
		$db->up();
43
44
		if( !$db->hasIndex( 'mshop_index_text', 'idx_msindte_content' ) )
45
		{
46
			$db->for( 'mysql', 'CREATE FULLTEXT INDEX `idx_msindte_content` ON `mshop_index_text` (`content`)' );
47
48
			try {
49
				$db->for( 'postgresql', 'CREATE INDEX "idx_msindte_content" ON "mshop_index_text" USING GIN (to_tsvector(\'english\', "content"))' );
50
			} catch( \Exception $e ) {
51
				// Doctrine DBAL bug: https://github.com/doctrine/dbal/issues/5351
52
			}
53
		}
54
	}
55
}
56