Completed
Pull Request — master (#32)
by Jakub
09:17
created

m8_priority   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 62
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A effectively_installed() 0 4 1
A depends_on() 0 4 1
A update_schema() 0 15 1
A revert_schema() 0 15 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 m8_priority extends \phpbb\db\migration\migration
14
{
15
	/**
16
	* {@inheritDoc}
17
	*/
18
	public function effectively_installed()
19
	{
20
		return $this->db_tools->sql_column_exists($this->table_prefix . 'ads', 'ad_priority');
21
	}
22
23
	/**
24
	* {@inheritDoc}
25
	*/
26
	static public function depends_on()
27
	{
28
		return array('\phpbb\ads\migrations\v10x\m1_initial_schema');
29
	}
30
31
	/**
32
	* Add the priority to ads table
33
	*
34
	* @return array Array of table schema
35
	* @access public
36
	*/
37
	public function update_schema()
38
	{
39
		return array(
40
			'add_columns' => array(
41
				$this->table_prefix . 'ads' => array(
42
					'ad_priority' => array('TINT:2', 5),
43
				),
44
			),
45
			'add_index'	=> array(
46
				$this->table_prefix . 'ads'	=> array(
47
					'ad_priority'	=> array('ad_priority'), // index used in ad\manager::get_ads
48
				),
49
			),
50
		);
51
	}
52
53
	/**
54
	* Drop the priority from ads table
55
	*
56
	* @return array Array of table schema
57
	* @access public
58
	*/
59
	public function revert_schema()
60
	{
61
		return array(
62
			'drop_keys'	=> array(
63
				$this->table_prefix . 'ads' => array(
64
					'ad_priority',
65
				),
66
			),
67
			'drop_columns' => array(
68
				$this->table_prefix . 'ads' => array(
69
					'ad_priority',
70
				),
71
			),
72
		);
73
	}
74
}
75