m1_initial_schema::effectively_installed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * Ideas extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ideas\migrations;
12
13
class m1_initial_schema extends \phpbb\db\migration\migration
14
{
15
	public function effectively_installed()
16
	{
17
		return $this->db_tools->sql_table_exists($this->table_prefix . 'ideas_ideas');
18
	}
19
20
	public static function depends_on()
21
	{
22
		return array('\phpbb\db\migration\data\v31x\v314');
23
	}
24
25
	public function update_schema()
26
	{
27
		return array(
28
			'add_tables'	=> array(
29
				$this->table_prefix . 'ideas_ideas' => array(
30
					'COLUMNS'	=> array(
31
						'idea_id'			=> array('UINT', null, 'auto_increment'),
32
						'idea_author'		=> array('UINT', 0),
33
						'idea_title'		=> array('VCHAR', ''),
34
						'idea_date'			=> array('TIMESTAMP', 0),
35
						'idea_votes_up'		=> array('UINT', 0),
36
						'idea_votes_down'	=> array('UINT', 0),
37
						'idea_status'		=> array('UINT', 1),
38
						'topic_id'			=> array('UINT', 0),
39
					),
40
					'PRIMARY_KEY'			=> 'idea_id',
41
				),
42
				$this->table_prefix . 'ideas_statuses' => array(
43
					'COLUMNS'	=> array(
44
						'status_id'			=> array('UINT', 0),
45
						'status_name'		=> array('VCHAR', ''),
46
					),
47
					'PRIMARY_KEY'			=> 'status_id',
48
				),
49
				$this->table_prefix . 'ideas_tickets' => array(
50
					'COLUMNS'	=> array(
51
						'idea_id'			=> array('UINT', 0),
52
						'ticket_id'			=> array('UINT', 0),
53
					),
54
					'KEYS'					=> array(
55
						'ticket_key' 		=> array('INDEX', array('idea_id', 'ticket_id')),
56
					),
57
				),
58
				$this->table_prefix . 'ideas_rfcs' => array(
59
					'COLUMNS'	=> array(
60
						'idea_id'			=> array('UINT', 0),
61
						'rfc_link'			=> array('VCHAR', ''),
62
					),
63
					'KEYS'					=> array(
64
						'rfc_key'			=> array('INDEX', array('idea_id', 'rfc_link')),
65
					),
66
				),
67
				$this->table_prefix . 'ideas_votes' => array(
68
					'COLUMNS'	=> array(
69
						'idea_id'			=> array('UINT', 0),
70
						'user_id'			=> array('UINT', 0),
71
						'vote_value'		=> array('BOOL', 0),
72
					),
73
					'KEYS'					=> array(
74
						'idea_id'			=> array('INDEX', array('idea_id', 'user_id')),
75
					),
76
				),
77
				$this->table_prefix . 'ideas_duplicates' => array(
78
					'COLUMNS'	=> array(
79
						'idea_id'			=> array('UINT', 0),
80
						'duplicate_id'		=> array('UINT', 0),
81
					),
82
					'KEYS'					=> array(
83
						'dupe_key'			=> array('INDEX', array('idea_id', 'duplicate_id')),
84
					),
85
				),
86
			),
87
		);
88
	}
89
90
	public function revert_schema()
91
	{
92
		return array(
93
			'drop_tables'	=> array(
94
				$this->table_prefix . 'ideas_ideas',
95
				$this->table_prefix . 'ideas_statuses',
96
				$this->table_prefix . 'ideas_tickets',
97
				$this->table_prefix . 'ideas_rfcs',
98
				$this->table_prefix . 'ideas_votes',
99
				$this->table_prefix . 'ideas_duplicates',
100
			),
101
		);
102
	}
103
}
104