1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Auto Generated from Blender |
5
|
|
|
* Date: 2017/11/10 at 15:29:37 EST -05:00 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
use \LCI\Blend\Migrations; |
9
|
|
|
|
10
|
|
|
class Update_000_009_007 extends Migrations |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Run the migrations. |
14
|
|
|
* |
15
|
|
|
* @return void |
16
|
|
|
*/ |
17
|
|
|
public function up() |
18
|
|
|
{ |
19
|
|
|
/** @var \xPDOManager $manager */ |
20
|
|
|
$manager = $this->modx->getManager(); |
21
|
|
|
|
22
|
|
|
// the class table object name |
23
|
|
|
$columns = $this->getCurrentColumns(); |
24
|
|
|
|
25
|
|
|
if (!in_array('author', $columns)) { |
26
|
|
|
if ($manager->addField('BlendMigrations', 'author', ['after' => 'status'])) { |
27
|
|
|
$this->blender->outSuccess('The author column was add to the BlendMigrations class (' . |
28
|
|
|
$this->modx->getTableName('BlendMigrations') . ') successfully'); |
29
|
|
|
|
30
|
|
|
} else { |
31
|
|
|
$this->blender->out('The author column was not added to the BlendMigrations class (' . |
32
|
|
|
$this->modx->getTableName('BlendMigrations') . ') successfully', true); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */ |
38
|
|
|
$systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting('blend.version'); |
39
|
|
|
$systemSetting |
40
|
|
|
->setSeedsDir($this->getSeedsDir()) |
41
|
|
|
->setFieldValue('0.9.7') |
42
|
|
|
->setFieldArea('Blend') |
43
|
|
|
->blend(true); |
44
|
|
|
|
45
|
|
|
$this->modx->cacheManager->refresh(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Reverse the migrations. |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function down() |
54
|
|
|
{ |
55
|
|
|
/** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */ |
56
|
|
|
$systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting('blend.version'); |
57
|
|
|
$systemSetting |
58
|
|
|
->setSeedsDir($this->getSeedsDir()) |
59
|
|
|
->revertBlend(); |
60
|
|
|
|
61
|
|
|
$this->modx->cacheManager->refresh(); |
62
|
|
|
|
63
|
|
|
$previous_version = $this->modx->getOption('blend.version'); |
64
|
|
|
if (!$previous_version || version_compare($this->getVersion(), $previous_version, '>') ) { |
65
|
|
|
|
66
|
|
|
/** @var \xPDOManager $manager */ |
67
|
|
|
$manager = $this->modx->getManager(); |
68
|
|
|
|
69
|
|
|
// the class table object name |
70
|
|
|
if ($manager->removeField('BlendMigrations', 'author', ['after' => 'status'])) { |
71
|
|
|
$this->blender->outSuccess('The author column was removed from the BlendMigrations class ('. |
72
|
|
|
$this->modx->getTableName('BlendMigrations').') successfully'); |
73
|
|
|
|
74
|
|
|
} else { |
75
|
|
|
$this->blender->out('The author column was not removed from the BlendMigrations class ('. |
76
|
|
|
$this->modx->getTableName('BlendMigrations').') successfully', true); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
protected function getCurrentColumns() |
82
|
|
|
{ |
83
|
|
|
$columns = []; |
84
|
|
|
|
85
|
|
|
$rs = $this->modx->query('SELECT * FROM ' . $this->modx->getTableName('BlendMigrations') . ' LIMIT 0'); |
86
|
|
|
for ($i = 0; $i < $rs->columnCount(); $i++) { |
87
|
|
|
$col = $rs->getColumnMeta($i); |
88
|
|
|
$columns[] = $col['name']; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $columns; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Method is called on construct, please fill me in |
96
|
|
|
*/ |
97
|
|
|
protected function assignDescription() |
98
|
|
|
{ |
99
|
|
|
$this->description = 'Update Blend to v0.9.7 from v0.9.6 and below'; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Method is called on construct, please fill me in |
104
|
|
|
*/ |
105
|
|
|
protected function assignVersion() |
106
|
|
|
{ |
107
|
|
|
$this->version = '0.9.7'; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Method is called on construct, can change to only run this migration for those types |
112
|
|
|
*/ |
113
|
|
|
protected function assignType() |
114
|
|
|
{ |
115
|
|
|
$this->type = 'master'; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Method is called on construct, Child class can override and implement this |
120
|
|
|
*/ |
121
|
|
|
protected function assignSeedsDir() |
122
|
|
|
{ |
123
|
|
|
$this->seeds_dir = 'Update_000_009_007'; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|