Passed
Push — release-3.0.0 ( e3b06e...069487 )
by Daniel
02:55
created

m1_initial_schema::update_schema()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 65
Code Lines 56

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 56
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 65
rs 8.9599

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\content\migrations\v30x;
11
12
class m1_initial_schema extends \phpbb\db\migration\migration
13
{
14
	/**
15
	 * @inheritdoc
16
	 */
17
	static public function depends_on()
18
	{
19
		return array(
20
			'\blitze\sitemaker\migrations\v31x\m310_filemanager',
21
		);
22
	}
23
24
	/**
25
	 * @inheritdoc
26
	 */
27
	public function update_schema()
28
	{
29
		return array(
30
			'add_tables'	=> array(
31
				$this->table_prefix . 'sm_content_types' => array(
32
					'COLUMNS'        => array(
33
						'content_id'			=> array('UINT', null, 'auto_increment'),
34
						'forum_id'				=> array('UINT', 0),
35
						'content_name'			=> array('VCHAR:125', ''),
36
						'content_langname'		=> array('VCHAR:155', ''),
37
						'content_enabled'		=> array('BOOL', 1),
38
						'content_colour'		=> array('VCHAR:6', ''),
39
						'content_desc'			=> array('TEXT_UNI', ''),
40
						'content_desc_bitfield'	=> array('VCHAR:255', ''),
41
						'content_desc_options'	=> array('UINT:11', 7),
42
						'content_desc_uid'		=> array('VCHAR:8', ''),
43
						'content_view'			=> array('VCHAR:155', ''),
44
						'content_view_settings'	=> array('VCHAR:255', ''),
45
						'req_approval'			=> array('BOOL', 1),
46
						'allow_comments'		=> array('BOOL', 1),
47
						'allow_views'			=> array('BOOL', 1),
48
						'show_poster_info'		=> array('BOOL', 1),
49
						'show_poster_contents'	=> array('BOOL', 1),
50
						'show_pagination'		=> array('BOOL', 1),
51
						'index_show_desc'		=> array('BOOL', 0),
52
						'items_per_page'		=> array('TINT:4', 1),
53
						'summary_tpl'			=> array('TEXT_UNI', ''),
54
						'detail_tpl'			=> array('TEXT_UNI', ''),
55
						'last_modified'			=> array('TIMESTAMP', 0)
56
					),
57
					'PRIMARY_KEY'	=> 'content_id',
58
					'KEYS'			=> array(
59
						'name'			=> array('INDEX', 'content_name'),
60
					),
61
				),
62
				$this->table_prefix . 'sm_content_fields' => array(
63
					'COLUMNS'        => array(
64
						'field_id'				=> array('UINT', null, 'auto_increment'),
65
						'content_id'			=> array('UINT', 0),
66
						'field_name'			=> array('VCHAR:125', ''),
67
						'field_label'			=> array('VCHAR:125', ''),
68
						'field_explain'			=> array('VCHAR:255', ''),
69
						'field_type'			=> array('VCHAR:55', ''),
70
						'field_props'			=> array('VCHAR:255', ''),
71
						'field_mod_only'		=> array('BOOL', 0),
72
						'field_required'		=> array('BOOL', 0),
73
						'field_summary_show'	=> array('VCHAR:10', ''),
74
						'field_detail_show'		=> array('VCHAR:10', ''),
75
						'field_summary_ldisp'	=> array('BOOL', 0),
76
						'field_detail_ldisp'	=> array('BOOL', 0),
77
						'field_exp_uid'			=> array('VCHAR:8', ''),
78
						'field_exp_bitfield'	=> array('VCHAR:255', ''),
79
						'field_exp_options'		=> array('UINT:11', 7),
80
						'field_order'			=> array('TINT:3', 0)
81
					),
82
					'PRIMARY_KEY'	=> 'field_id',
83
					'KEYS'			=> array(
84
						'cid'			=> array('INDEX', 'content_id'),
85
					),
86
				),
87
			),
88
			'add_columns'	=> array(
89
				$this->table_prefix . 'topics'		=> array(
90
					'topic_slug'		=> array('VCHAR:255', ''),
91
					'req_mod_input'		=> array('BOOL', 0),
92
				)
93
			),
94
		);
95
	}
96
97
	/**
98
	 * {@inheritdoc}
99
	 */
100
	public function revert_schema()
101
	{
102
		return array(
103
			'drop_tables'	=> array(
104
				$this->table_prefix . 'sm_content_types',
105
				$this->table_prefix . 'sm_content_fields',
106
			),
107
			'drop_columns'	=> array(
108
				$this->table_prefix . 'topics'		=> array(
109
					'topic_slug',
110
					'req_mod_input'
111
				)
112
			),
113
		);
114
	}
115
}
116