Completed
Pull Request — master (#24)
by Jakub
12:01 queued 04:37
created

m4_indexes   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 61
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A effectively_installed() 0 4 1
A depends_on() 0 7 1
A update_schema() 0 13 1
A revert_schema() 0 13 1
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(
29
			'\phpbb\ads\migrations\v10x\m1_initial_schema',
30
			'\phpbb\ads\migrations\v10x\m3_template_locations_schema'
31
		);
32
	}
33
34
	/**
35
	* Add the indexes
36
	*
37
	* @return array Array of altered table schema
38
	* @access public
39
	*/
40
	public function update_schema()
41
	{
42
		return array(
43
			'add_index'	=> array(
44
				$this->table_prefix . 'ads'	=> array(
45
					'ad_enabled'	=> array('ad_enabled'), // index used in ad\manager::get_ads
46
				),
47
				$this->table_prefix . 'ad_locations'	=> array(
48
					'location_id'	=> array('location_id'), // index used in ad\manager::get_ads
49
				),
50
			),
51
		);
52
	}
53
54
	/**
55
	* Drop the indexes
56
	*
57
	* @return array Array of altered table schema
58
	* @access public
59
	*/
60
	public function revert_schema()
61
	{
62
		return array(
63
			'drop_keys'	=> array(
64
				$this->table_prefix . 'ad_locations' => array(
65
					'location_id',
66
				),
67
				$this->table_prefix . 'ads' => array(
68
					'ad_enabled',
69
				),
70
			),
71
		);
72
	}
73
}
74