Completed
Branch release-3.2.0 (10f575)
by Daniel
03:11
created

m1_initial_schema   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 68
c 3
b 0
f 0
dl 0
loc 108
rs 10
wmc 3
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
			'\phpbb\db\migration\data\v31x\v312',
21
			'\blitze\sitemaker\migrations\converter\c3_update_tables',
22
			'\blitze\sitemaker\migrations\v20x\m3_initial_permission',
23
		);
24
	}
25
26
	/**
27
	 * @inheritdoc
28
	 */
29
	public function update_schema()
30
	{
31
		return array(
32
			'add_tables'	=> array(
33
				$this->table_prefix . 'sm_block_routes' => array(
34
					'COLUMNS'		=> array(
35
						'route_id'		=> array('UINT', null, 'auto_increment'),
36
						'ext_name'		=> array('VCHAR:255', ''),
37
						'route'			=> array('XSTEXT_UNI', ''),
38
						'style'			=> array('USINT', 0),
39
						'hide_blocks'	=> array('BOOL', 0),
40
						'has_blocks'	=> array('BOOL', 0),
41
						'ex_positions'	=> array('VCHAR:255', ''),
42
					),
43
44
					'PRIMARY_KEY'	=> 'route_id'
45
				),
46
47
				$this->table_prefix . 'sm_blocks' => array(
48
					'COLUMNS'		=> array(
49
						'bid'			=> array('UINT', null, 'auto_increment'),
50
						'icon'			=> array('VCHAR:55', ''),
51
						'name'			=> array('VCHAR:55', ''),
52
						'title'			=> array('XSTEXT_UNI', ''),
53
						'route_id'		=> array('UINT', 0),
54
						'position'		=> array('VCHAR:55', ''),
55
						'weight'		=> array('USINT', 0),
56
						'style'			=> array('USINT', 0),
57
						'permission'	=> array('VCHAR:125', ''),
58
						'class'			=> array('VCHAR:125', ''),
59
						'status'		=> array('BOOL', 1),
60
						'type'			=> array('BOOL', 0),
61
						'no_wrap'		=> array('BOOL', 0),
62
						'hide_title'	=> array('BOOL', 0),
63
						'hash'			=> array('VCHAR:32', ''),
64
					),
65
66
					'PRIMARY_KEY'	=> 'bid',
67
68
					'KEYS'			=> array(
69
						'style'			=> array('INDEX', 'style'),
70
					),
71
				),
72
73
				$this->table_prefix . 'sm_menus' => array(
74
					'COLUMNS'        => array(
75
						'menu_id'			=> array('UINT', null, 'auto_increment'),
76
						'menu_name'			=> array('VCHAR:55', ''),
77
					),
78
					'PRIMARY_KEY'	=> 'menu_id',
79
					'KEYS'			=> array(
80
						'menu_name'			=> array('UNIQUE', 'menu_name'),
81
						'menu_id'			=> array('INDEX', 'menu_id'),
82
					),
83
				),
84
85
				$this->table_prefix . 'sm_menu_items' => array(
86
					'COLUMNS'        => array(
87
						'item_id'			=> array('UINT', null, 'auto_increment'),
88
						'menu_id'			=> array('UINT', 0),
89
						'group_id'			=> array('UINT', 0),
90
						'parent_id'			=> array('UINT', 0),
91
						'item_title'		=> array('XSTEXT_UNI', ''),
92
						'item_url'			=> array('VCHAR_UNI', ''),
93
						'item_icon'			=> array('VCHAR', ''),
94
						'item_desc'			=> array('VCHAR:55', ''),
95
						'item_target'		=> array('BOOL', 0),
96
						'left_id'			=> array('UINT', 0),
97
						'right_id'			=> array('UINT', 0),
98
						'depth'				=> array('UINT', 0),
99
					),
100
					'PRIMARY_KEY'	=> 'item_id',
101
					'KEYS'			=> array(
102
						'menu_id'		=> array('INDEX', 'menu_id'),
103
					),
104
				),
105
			),
106
		);
107
	}
108
109
	/**
110
	 * @inheritdoc
111
	 */
112
	public function revert_schema()
113
	{
114
		return array(
115
			'drop_tables'	=> array(
116
				$this->table_prefix . 'sm_blocks',
117
				$this->table_prefix . 'sm_block_routes',
118
				$this->table_prefix . 'sm_menus',
119
				$this->table_prefix . 'sm_menu_items',
120
			),
121
		);
122
	}
123
}
124