Passed
Push — master ( a62c96...39b502 )
by Sylver
03:39
created

smiliescat_1_7_0   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 57
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A effectively_installed() 0 3 1
A update_data() 0 5 1
A revert_schema() 0 6 1
A update_schema() 0 17 1
A update_display_on_cat() 0 3 1
A depends_on() 0 3 1
1
<?php
2
/**
3
*
4
* @package		Breizh Smilies Categories Extension
5
* @copyright	(c) 2020-2024 Sylver35  https://breizhcode.com
6
* @license		https://opensource.org/licenses/gpl-license.php GNU Public License
7
*
8
*/
9
10
namespace sylver35\smiliescat\migrations;
11
12
use phpbb\db\migration\migration;
13
14
class smiliescat_1_7_0 extends migration
15
{
16
	public function effectively_installed()
17
	{
18
		return $this->db_tools->sql_column_exists($this->table_prefix . 'smilies', 'display_on_cat');
19
	}
20
21
	static public function depends_on()
22
	{
23
		return ['\sylver35\smiliescat\migrations\smiliescat_1_6_1'];
24
	}
25
26
	public function update_schema()
27
	{
28
		return [
29
			'change_columns' => [
30
				$this->table_prefix . 'smilies' => [
31
					'category' => ['UINT', '9998'],
32
				],
33
			],
34
			'add_columns' => [
35
				$this->table_prefix . 'smilies' => [
36
					'display_on_cat'	=> ['UINT', 1],
37
				],
38
			],
39
			'add_index' => [
40
				$this->table_prefix . 'smilies' => [
41
					'display_on_cat'	=> ['display_on_cat'],
42
					'category'			=> ['category'],
43
				],
44
			],
45
		];
46
	}
47
48
	public function update_data()
49
	{
50
		return [
51
			['custom', [
52
				[&$this, 'update_display_on_cat']
53
			]],
54
		];
55
	}
56
57
	public function revert_schema()
58
	{
59
		return [
60
			'drop_columns' => [
61
				$this->table_prefix . 'smilies' => [
62
					'display_on_cat',
63
				],
64
			],
65
		];
66
	}
67
68
	public function update_display_on_cat()
69
	{
70
		$this->db->sql_query('UPDATE ' . $this->table_prefix . 'smilies SET category = 9998 WHERE category = 0');
71
	}
72
}
73