Completed
Push — master ( 3f27cb...915db5 )
by Mario
05:56 queued 02:52
created

v310_m1_schema::revert_schema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * PayPal Donation extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2015 Skouat
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace skouat\ppde\migrations\v31x;
12
13
class v310_m1_schema extends \phpbb\db\migration\migration
14
{
15
	public static function depends_on()
16
	{
17
		return array('\skouat\ppde\migrations\v30x\v300_m1_converter_data');
18
	}
19
20
	/**
21
	 * Add the table schema to the database:
22
	 *
23
	 * @return array Array of table schema
24
	 * @access public
25
	 */
26
	public function update_schema()
27
	{
28
		return array(
29
			'add_tables' => array(
30
				$this->table_prefix . 'ppde_currency'       => array(
31
					'COLUMNS'     => array(
32
						'currency_id'       => array('UINT', null, 'auto_increment'),
33
						'currency_name'     => array('VCHAR:50', ''),
34
						'currency_iso_code' => array('VCHAR:10', ''),
35
						'currency_symbol'   => array('VCHAR:10', ''),
36
						'currency_on_left'  => array('BOOL', 1),
37
						'currency_enable'   => array('BOOL', 1),
38
						'currency_order'    => array('UINT', 0),
39
					),
40
					'PRIMARY_KEY' => array('currency_id'),
41
				),
42
43
				$this->table_prefix . 'ppde_donation_pages' => array(
44
					'COLUMNS'     => array(
45
						'page_id'                      => array('UINT', null, 'auto_increment'),
46
						'page_title'                   => array('VCHAR:50', ''),
47
						'page_lang_id'                 => array('UINT', 0),
48
						'page_content'                 => array('TEXT', ''),
49
						'page_content_bbcode_bitfield' => array('VCHAR:255', ''),
50
						'page_content_bbcode_uid'      => array('VCHAR:8', ''),
51
						'page_content_bbcode_options'  => array('UINT:4', 7),
52
					),
53
54
					'PRIMARY_KEY' => array('page_id'),
55
				),
56
57
				$this->table_prefix . 'ppde_txn_log'        => array(
58
					'COLUMNS'     => array(
59
						'transaction_id'    => array('UINT', null, 'auto_increment'),
60
						// Receiver information
61
						'receiver_id'       => array('VCHAR:13', ''),
62
						'receiver_email'    => array('VCHAR:127', ''),
63
						'residence_country' => array('VCHAR:2', ''),
64
						'business'          => array('VCHAR:127', ''),
65
						// Transaction information
66
						'confirmed'         => array('BOOL', 0),
67
						'test_ipn'          => array('BOOL', 0),
68
						'txn_id'            => array('VCHAR:32', ''),
69
						'txn_type'          => array('VCHAR:32', ''),
70
						'parent_txn_id'     => array('VCHAR:19', ''),
71
						// Buyer information
72
						'payer_email'       => array('VCHAR:127', ''),
73
						'payer_id'          => array('VCHAR:13', ''),
74
						'payer_status'      => array('VCHAR:16', ''),
75
						'first_name'        => array('VCHAR:64', ''),
76
						'last_name'         => array('VCHAR:64', ''),
77
						'user_id'           => array('UINT', 0),
78
						// Payment information
79
						'custom'            => array('VCHAR:255', ''),
80
						'item_name'         => array('VCHAR:128', ''),
81
						'item_number'       => array('VCHAR:128', ''),
82
						'mc_currency'       => array('VCHAR:8', ''),
83
						'mc_fee'            => array('DECIMAL:8', 0),
84
						'mc_gross'          => array('DECIMAL:8', 0),
85
						'payment_date'      => array('TIMESTAMP', 0),
86
						'payment_status'    => array('VCHAR:18', ''),
87
						'payment_type'      => array('VCHAR:10', ''),
88
						'settle_amount'     => array('DECIMAL:8', 0),
89
						'settle_currency'   => array('VCHAR:8', ''),
90
						'net_amount'        => array('DECIMAL:8', 0),
91
						'exchange_rate'     => array('VCHAR:16', ''),
92
					),
93
94
					'PRIMARY_KEY' => array('transaction_id'),
95
					'KEYS'        => array(
96
						'user_id' => array('INDEX', 'user_id'),
97
						'txn_id'  => array('INDEX', 'txn_id'),
98
					),
99
				),
100
			),
101
		);
102
	}
103
104
	/**
105
	 * Drop the PayPal Donation tables schema from the database
106
	 *
107
	 * @return array Array of table schema
108
	 * @access public
109
	 */
110
	public function revert_schema()
111
	{
112
		return array(
113
			'drop_tables' => array(
114
				$this->table_prefix . 'ppde_currency',
115
				$this->table_prefix . 'ppde_donation_pages',
116
				$this->table_prefix . 'ppde_txn_log',
117
			),
118
		);
119
	}
120
}
121