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 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('\phpbb\ads\migrations\v10x\m1_initial_schema'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Add the views and clicks to ads table |
33
|
|
|
* |
34
|
|
|
* @return array Array of table schema |
35
|
|
|
* @access public |
36
|
|
|
*/ |
37
|
|
|
public function update_schema() |
38
|
|
|
{ |
39
|
|
|
return array( |
40
|
|
|
'add_columns' => array( |
41
|
|
|
$this->table_prefix . 'ads' => array( |
42
|
|
|
'ad_views' => array('UINT', 0), |
43
|
|
|
'ad_clicks' => array('UINT', 0), |
44
|
|
|
'ad_views_limit' => array('UINT', 0), |
45
|
|
|
'ad_clicks_limit' => array('UINT', 0), |
46
|
|
|
), |
47
|
|
|
), |
48
|
|
|
); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Drop the views and clicks from ads table |
53
|
|
|
* |
54
|
|
|
* @return array Array of table schema |
55
|
|
|
* @access public |
56
|
|
|
*/ |
57
|
|
|
public function revert_schema() |
58
|
|
|
{ |
59
|
|
|
return array( |
60
|
|
|
'drop_columns' => array( |
61
|
|
|
$this->table_prefix . 'ads' => array( |
62
|
|
|
'ad_views', |
63
|
|
|
'ad_clicks', |
64
|
|
|
'ad_views_limit', |
65
|
|
|
'ad_clicks_limit', |
66
|
|
|
), |
67
|
|
|
), |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Add phpbb_ads_enable_views and phpbb_ads_enable_clicks config |
73
|
|
|
* |
74
|
|
|
* @return array Array of data update instructions |
75
|
|
|
*/ |
76
|
|
|
public function update_data() |
77
|
|
|
{ |
78
|
|
|
return array( |
79
|
|
|
array('config.add', array('phpbb_ads_enable_views', 0)), |
80
|
|
|
array('config.add', array('phpbb_ads_enable_clicks', 0)), |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|