Completed
Pull Request — master (#46)
by Matt
58:39 queued 23:45
created

m9_views_clicks::depends_on()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
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 m9_views_clicks 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_views');
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
			'\phpbb\ads\migrations\v10x\m4_indexes',
32
			'\phpbb\ads\migrations\v10x\m5_end_date',
33
			'\phpbb\ads\migrations\v10x\m8_priority',
34
		);
35
	}
36
37
	/**
38
	* Add the views and clicks to ads table
39
	*
40
	* @return array Array of table schema
41
	* @access public
42
	*/
43
	public function update_schema()
44
	{
45
		return array(
46
			'add_columns' => array(
47
				$this->table_prefix . 'ads' => array(
48
					'ad_views'			=> array('UINT', 0),
49
					'ad_clicks'			=> array('UINT', 0),
50
					'ad_views_limit'	=> array('UINT', 0),
51
					'ad_clicks_limit'	=> array('UINT', 0),
52
				),
53
			),
54
		);
55
	}
56
57
	/**
58
	* Drop the views and clicks from ads table
59
	*
60
	* @return array Array of table schema
61
	* @access public
62
	*/
63
	public function revert_schema()
64
	{
65
		return array(
66
			'drop_columns' => array(
67
				$this->table_prefix . 'ads' => array(
68
					'ad_views',
69
					'ad_clicks',
70
					'ad_views_limit',
71
					'ad_clicks_limit',
72
				),
73
			),
74
		);
75
	}
76
}
77