Completed
Pull Request — master (#116)
by Matt
14:26
created

m13_content_only::revert_schema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 8
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 m13_content_only 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_content_only');
21
	}
22
23
	/**
24
	 * {@inheritDoc}
25
	 */
26
	public static function depends_on()
27
	{
28
		return array(
29
			'\phpbb\ads\migrations\v10x\m1_initial_schema',
30
			'\phpbb\ads\migrations\v10x\m4_indexes',
31
		);
32
	}
33
34
	/**
35
	 * Add the ad_content_only to ads table
36
	 *
37
	 * @return array Array of table schema
38
	 * @access public
39
	 */
40
	public function update_schema()
41
	{
42
		return array(
43
			'add_columns' => array(
44
				$this->table_prefix . 'ads' => array(
45
					'ad_content_only' => array('BOOL', 0),
46
				),
47
			),
48
			'add_index'	=> array(
49
				$this->table_prefix . 'ads'	=> array(
50
					'ad_co'	=> array('ad_content_only'), // index used in ad\manager::get_ads
51
				),
52
			),
53
		);
54
	}
55
56
	/**
57
	 * Drop the ad_content_only from ads table
58
	 *
59
	 * @return array Array of table schema
60
	 * @access public
61
	 */
62
	public function revert_schema()
63
	{
64
		return array(
65
			'drop_keys'	=> array(
66
				$this->table_prefix . 'ads' => array(
67
					'ad_co',
68
				),
69
			),
70
			'drop_columns' => array(
71
				$this->table_prefix . 'ads' => array(
72
					'ad_content_only',
73
				),
74
			),
75
		);
76
	}
77
}
78