1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Advertisement management. An extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2017 phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\ads\migrations\v10x; |
12
|
|
|
|
13
|
|
|
class m9_views_clicks_schema extends \phpbb\db\migration\migration |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
|
|
public function effectively_installed() |
19
|
|
|
{ |
20
|
|
|
return $this->db_tools->sql_column_exists($this->table_prefix . 'ads', 'ad_views'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
*/ |
26
|
|
|
static public function depends_on() |
27
|
|
|
{ |
28
|
|
|
return array( |
29
|
|
|
'\phpbb\ads\migrations\v10x\m1_initial_schema', |
30
|
|
|
'\phpbb\ads\migrations\v10x\m8_priority', |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Add the views and clicks to ads table |
36
|
|
|
* |
37
|
|
|
* @return array Array of table schema |
38
|
|
|
* @access public |
39
|
|
|
*/ |
40
|
|
|
public function update_schema() |
41
|
|
|
{ |
42
|
|
|
return array( |
43
|
|
|
'add_columns' => array( |
44
|
|
|
$this->table_prefix . 'ads' => array( |
45
|
|
|
'ad_views' => array('UINT', 0), |
46
|
|
|
'ad_clicks' => array('UINT', 0), |
47
|
|
|
'ad_views_limit' => array('UINT', 0), |
48
|
|
|
'ad_clicks_limit' => array('UINT', 0), |
49
|
|
|
), |
50
|
|
|
), |
51
|
|
|
'add_index' => array( |
52
|
|
|
$this->table_prefix . 'ads' => array( |
53
|
|
|
'ad_views' => array('ad_views'), // index used in ad\manager::get_ads |
54
|
|
|
'ad_clicks' => array('ad_clicks'), // index used in ad\manager::get_ads |
55
|
|
|
'ad_views_limit' => array('ad_views_limit'), // index used in ad\manager::get_ads |
56
|
|
|
'ad_clicks_limit' => array('ad_clicks_limit'), // index used in ad\manager::get_ads |
57
|
|
|
), |
58
|
|
|
), |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Drop the views and clicks from ads table |
64
|
|
|
* |
65
|
|
|
* @return array Array of table schema |
66
|
|
|
* @access public |
67
|
|
|
*/ |
68
|
|
|
public function revert_schema() |
69
|
|
|
{ |
70
|
|
|
return array( |
71
|
|
|
'drop_keys' => array( |
72
|
|
|
$this->table_prefix . 'ads' => array( |
73
|
|
|
'ad_clicks_limit', |
74
|
|
|
'ad_views_limit', |
75
|
|
|
'ad_clicks', |
76
|
|
|
'ad_views', |
77
|
|
|
), |
78
|
|
|
), |
79
|
|
|
'drop_columns' => array( |
80
|
|
|
$this->table_prefix . 'ads' => array( |
81
|
|
|
'ad_views', |
82
|
|
|
'ad_clicks', |
83
|
|
|
'ad_views_limit', |
84
|
|
|
'ad_clicks_limit', |
85
|
|
|
), |
86
|
|
|
), |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|