Completed
Pull Request — master (#24)
by Jakub
15:23 queued 13:00
created

m4_indexes::depends_on()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ads\migrations\v10x;
12
13
class m4_indexes extends \phpbb\db\migration\migration
14
{
15
	/**
16
	* {@inheritDoc}
17
	*/
18
	public function effectively_installed()
19
	{
20
		return $this->db_tools->sql_index_exists($this->table_prefix . 'ads', 'ad_enabled');
21
	}
22
23
	/**
24
	* {@inheritDoc}
25
	*/
26
	static public function depends_on()
27
	{
28
		return array('\phpbb\ads\migrations\v10x\m3_template_locations_schema');
29
	}
30
31
	/**
32
	* Add the indexes
33
	*
34
	* @return array Array of altered table schema
35
	* @access public
36
	*/
37
	public function update_schema()
38
	{
39
		return array(
40
			'add_index'	=> array(
41
				$this->table_prefix . 'ads'	=> array(
42
					'ad_enabled'	=> array('ad_enabled'), // index used in ad\manager::get_ads
43
				),
44
				$this->table_prefix . 'ad_locations'	=> array(
45
					'location_id'	=> array('location_id'), // index used in ad\manager::get_ads
46
				),
47
			),
48
		);
49
	}
50
51
	/**
52
	* Drop the indexes
53
	*
54
	* @return array Array of altered table schema
55
	* @access public
56
	*/
57
	public function revert_schema()
58
	{
59
		return array(
60
			'drop_keys'	=> array(
61
				$this->table_prefix . 'ad_locations' => array(
62
					'location_id',
63
				),
64
				$this->table_prefix . 'ads' => array(
65
					'ad_enabled',
66
				),
67
			),
68
		);
69
	}
70
}
71