|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Precise Similar Topics |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2018 Matt Friedman |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace vse\similartopics\migrations\release_1_5_x; |
|
12
|
|
|
|
|
13
|
|
|
class postgres_index extends \phpbb\db\migration\migration |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Do not run this migration if the DB is not PostgreSQL |
|
17
|
|
|
* |
|
18
|
|
|
* @return bool |
|
19
|
|
|
*/ |
|
20
|
|
|
public function effectively_installed() |
|
21
|
|
|
{ |
|
22
|
|
|
return $this->db->get_sql_layer() !== 'postgres' || $this->config->offsetExists('pst_postgres_ts_name'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public static function depends_on() |
|
26
|
|
|
{ |
|
27
|
|
|
return array('\vse\similartopics\migrations\release_1_4_3_data'); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function update_data() |
|
31
|
|
|
{ |
|
32
|
|
|
return array( |
|
33
|
|
|
array('config.add', array('pst_postgres_ts_name', $this->get_ts_name())), |
|
34
|
|
|
array('if', array( |
|
35
|
|
|
$this->db->get_sql_layer() === 'postgres', |
|
36
|
|
|
array('custom', array(array($this, 'create_postgres_index'))), |
|
37
|
|
|
)), |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function revert_data() |
|
42
|
|
|
{ |
|
43
|
|
|
return array( |
|
44
|
|
|
array('if', array( |
|
45
|
|
|
$this->db->get_sql_layer() === 'postgres', |
|
46
|
|
|
array('custom', array(array($this, 'drop_postgres_changes'))), |
|
47
|
|
|
)), |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Create PostgreSQL FULLTEXT index for the topic_title |
|
53
|
|
|
*/ |
|
54
|
|
|
public function create_postgres_index() |
|
55
|
|
|
{ |
|
56
|
|
|
$driver = $this->get_driver(); |
|
57
|
|
|
$driver->create_fulltext_index(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Drop the PostgreSQL FULLTEXT index on phpbb_topics.topic_title |
|
62
|
|
|
*/ |
|
63
|
|
|
public function drop_postgres_changes() |
|
64
|
|
|
{ |
|
65
|
|
|
$driver = $this->get_driver(); |
|
66
|
|
|
|
|
67
|
|
|
foreach ($driver->get_fulltext_indexes() as $index) |
|
68
|
|
|
{ |
|
69
|
|
|
$sql = 'DROP INDEX ' . $index; |
|
70
|
|
|
$this->db->sql_query($sql); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Get an instance of the similartopics POSTGRES driver |
|
76
|
|
|
* |
|
77
|
|
|
* @return \vse\similartopics\driver\postgres |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function get_driver() |
|
80
|
|
|
{ |
|
81
|
|
|
return new \vse\similartopics\driver\postgres($this->db, $this->config); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
protected function get_ts_name() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->config->offsetExists('fulltext_postgres_ts_name') ? $this->config['fulltext_postgres_ts_name'] : 'simple'; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths