rc3::update_schema()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * @package Quick Title Edition Extension
5
 * @copyright (c) 2015 ABDev
6
 * @copyright (c) 2015 PastisD
7
 * @copyright (c) 2015 Geolim4 <http://geolim4.com>
8
 * @copyright (c) 2015 Zoddo <[email protected]>
9
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
10
 *
11
 */
12
13
namespace ernadoo\qte\migrations\v100;
14
15
class rc3 extends \phpbb\db\migration\migration
16
{
17
	static public function depends_on()
18
	{
19
		return array('\phpbb\db\migration\data\v310\dev');
20
	}
21
22
	public function effectively_installed()
23
	{
24
		return isset($this->config['qte_version']) && phpbb_version_compare($this->config['qte_version'], '1.0.0-rc3', '>=');
25
	}
26
27
	public function update_data()
28
	{
29
		return array(
30
			array('config.add', array('qte_version', '1.0.0-rc3')),
31
			array('config.add', array('qte_force_users', false)),
32
33
			array('permission.add', array('a_attr_manage')),
34
			array('permission.permission_set', array('ROLE_ADMIN_FULL', 'a_attr_manage')),
35
			array('permission.permission_set', array('ROLE_ADMIN_FORUM', 'a_attr_manage')),
36
			array('permission.permission_set', array('ROLE_ADMIN_STANDARD', 'a_attr_manage')),
37
		);
38
	}
39
40
	public function update_schema()
41
	{
42
		return array(
43
			'add_tables'		=> array(
44
				$this->table_prefix . 'topics_attr'		=> array(
45
					'COLUMNS'		  => array(
46
						'attr_id'			=> array('UINT', null, 'auto_increment'),
47
						'attr_type'			=> array('BOOL', 0),
48
						'attr_name'			=> array('VCHAR', ''),
49
						'left_id'			=> array('UINT', 0),
50
						'right_id'			=> array('UINT', 0),
51
						'attr_img'			=> array('VCHAR', ''),
52
						'attr_date'			=> array('VCHAR:30', ''),
53
						'attr_colour'		=> array('VCHAR:6', ''),
54
						'attr_user_colour'	=> array('BOOL', 0),
55
						'allowed_forums'	=> array('TEXT', ''),
56
						'allowed_groups'	=> array('TEXT', ''),
57
					),
58
					'PRIMARY_KEY'		=> 'attr_id',
59
				),
60
			),
61
			'add_columns'	   => array(
62
				TOPICS_TABLE		   => array(
63
					'topic_attr_id'     => array('UINT', 0),
64
					'topic_attr_user'   => array('UINT', 0),
65
					'topic_attr_time'   => array('TIMESTAMP', 0),
66
				),
67
			),
68
		);
69
	}
70
71
	public function revert_schema()
72
	{
73
		return array(
74
			'drop_tables'		=> array(
75
				$this->table_prefix . 'topics_attr',
76
			),
77
			'drop_columns'	   => array(
78
				TOPICS_TABLE		   => array(
79
					'topic_attr_id',
80
					'topic_attr_user',
81
					'topic_attr_time',
82
				),
83
			),
84
		);
85
	}
86
}
87