Completed
Push — develop ( 6f1d60...1f2a5d )
by Daniel
11:12
created

m1_initial_schema::update_schema()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 91
Code Lines 65

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 91
rs 8.518
cc 1
eloc 65
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\migrations\v20x;
11
12
class m1_initial_schema extends \phpbb\db\migration\migration
13
{
14
	/**
15
	 * @inheritdoc
16
	 */
17
	public static function depends_on()
18
	{
19
		return array(
20
			'\blitze\sitemaker\migrations\converter\c3_update_tables',
21
			'\blitze\sitemaker\migrations\v20x\m3_initial_permission',
22
		);
23
	}
24
25
	/**
26
	 * @inheritdoc
27
	 */
28
	public function update_schema()
29
	{
30
		return array(
31
			'add_tables'	=> array(
32
				$this->table_prefix . 'sm_block_routes' => array(
33
					'COLUMNS'		=> array(
34
						'route_id'		=> array('UINT', null, 'auto_increment'),
35
						'ext_name'		=> array('VCHAR:255', ''),
36
						'route'			=> array('XSTEXT_UNI', ''),
37
						'style'			=> array('USINT', 0),
38
						'hide_blocks'	=> array('BOOL', 0),
39
						'has_blocks'	=> array('BOOL', 0),
40
						'ex_positions'	=> array('VCHAR:255', ''),
41
					),
42
43
					'PRIMARY_KEY'	=> 'route_id'
44
				),
45
46
				$this->table_prefix . 'sm_blocks' => array(
47
					'COLUMNS'		=> array(
48
						'bid'			=> array('UINT', null, 'auto_increment'),
49
						'icon'			=> array('VCHAR:55', ''),
50
						'name'			=> array('VCHAR:55', ''),
51
						'title'			=> array('XSTEXT_UNI', ''),
52
						'route_id'		=> array('UINT', 0),
53
						'position'		=> array('VCHAR:55', ''),
54
						'weight'		=> array('USINT', 0),
55
						'style'			=> array('USINT', 0),
56
						'permission'	=> array('VCHAR:125', ''),
57
						'class'			=> array('VCHAR:125', ''),
58
						'status'		=> array('BOOL', 1),
59
						'type'			=> array('BOOL', 0),
60
						'no_wrap'		=> array('BOOL', 0),
61
						'hide_title'	=> array('BOOL', 0),
62
						'hash'			=> array('VCHAR:32', ''),
63
					),
64
65
					'PRIMARY_KEY'	=> 'bid',
66
67
					'KEYS'			=> array(
68
						'style'			=> array('INDEX', 'style'),
69
					),
70
				),
71
72
				$this->table_prefix . 'sm_menus' => array(
73
					'COLUMNS'        => array(
74
						'menu_id'			=> array('UINT', null, 'auto_increment'),
75
						'menu_name'			=> array('VCHAR:55', ''),
76
					),
77
					'PRIMARY_KEY'	=> 'menu_id',
78
					'KEYS'			=> array(
79
						'menu_name'			=> array('UNIQUE', 'menu_name'),
80
						'menu_id'			=> array('INDEX', 'menu_id'),
81
					),
82
				),
83
84
				$this->table_prefix . 'sm_menu_items' => array(
85
					'COLUMNS'        => array(
86
						'item_id'			=> array('UINT', null, 'auto_increment'),
87
						'menu_id'			=> array('UINT', 0),
88
						'group_id'			=> array('UINT', 0),
89
						'parent_id'			=> array('UINT', 0),
90
						'item_title'		=> array('XSTEXT_UNI', ''),
91
						'item_url'			=> array('VCHAR_UNI', ''),
92
						'item_icon'			=> array('VCHAR', ''),
93
						'item_desc'			=> array('VCHAR:55', ''),
94
						'item_target'		=> array('BOOL', 0),
95
						'left_id'			=> array('UINT', 0),
96
						'right_id'			=> array('UINT', 0),
97
						'depth'				=> array('UINT', 0),
98
					),
99
					'PRIMARY_KEY'	=> 'item_id',
100
					'KEYS'			=> array(
101
						'menu_id'		=> array('INDEX', 'menu_id'),
102
					),
103
				),
104
			),
105
			'add_columns'	=> array(
106
				$this->table_prefix . 'forums'	=> array(
107
					'hidden_forum'		=> array('BOOL', 0),
108
				),
109
			),
110
		);
111
	}
112
113
	/**
114
	 * @inheritdoc
115
	 */
116
	public function revert_schema()
117
	{
118
		return array(
119
			'drop_tables'	=> array(
120
				$this->table_prefix . 'sm_blocks',
121
				$this->table_prefix . 'sm_blocks_config',
122
				$this->table_prefix . 'sm_block_routes',
123
				$this->table_prefix . 'sm_menus',
124
				$this->table_prefix . 'sm_menu_items',
125
			),
126
		);
127
	}
128
}
129