1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Phinx\Migration\AbstractMigration; |
4
|
|
|
|
5
|
|
|
class PageStatusConversion extends AbstractMigration |
6
|
|
|
{ |
7
|
|
|
public function up() |
8
|
|
|
{ |
9
|
|
|
$pagesTable = $this->table('pages'); |
10
|
|
|
$pagesTable |
11
|
|
|
->addColumn('is_unlisted', 'boolean', [ |
12
|
|
|
'after' => 'home', |
13
|
|
|
'null' => false, |
14
|
|
|
'default' => false, |
15
|
|
|
'comment' => 'Whether or not this page should be listed in the secondary navigation', |
16
|
|
|
]) |
17
|
|
|
->addColumn('is_draft', 'boolean', [ |
18
|
|
|
'after' => 'is_unlisted', |
19
|
|
|
'null' => false, |
20
|
|
|
'default' => false, |
21
|
|
|
'comment' => 'Whether or not the news article is a draft', |
22
|
|
|
]) |
23
|
|
|
->addColumn('is_deleted', 'boolean', [ |
24
|
|
|
'after' => 'is_draft', |
25
|
|
|
'null' => false, |
26
|
|
|
'default' => false, |
27
|
|
|
'comment' => 'Whether or not this entry has been soft-deleted', |
28
|
|
|
]) |
29
|
|
|
->update() |
30
|
|
|
; |
31
|
|
|
|
32
|
|
|
$this->query("UPDATE pages SET is_deleted = 1 WHERE status = 'deleted';"); |
33
|
|
|
$this->query("UPDATE pages SET is_unlisted = 1 WHERE status = 'revision';"); |
34
|
|
|
|
35
|
|
|
$pagesTable |
36
|
|
|
->removeColumn('parent_id') |
37
|
|
|
->removeColumn('home') |
38
|
|
|
->removeColumn('status') |
39
|
|
|
->update() |
40
|
|
|
; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function down() |
44
|
|
|
{ |
45
|
|
|
$pagesTable = $this->table('pages'); |
46
|
|
|
$pagesTable |
47
|
|
|
->addColumn('parent_id', 'integer', [ |
48
|
|
|
'after' => 'id', |
49
|
|
|
'null' => true, |
50
|
|
|
'default' => null, |
51
|
|
|
'length' => 10, |
52
|
|
|
'comment' => 'The ID of the original page. If this column is set, then it is a revision', |
53
|
|
|
]) |
54
|
|
|
->addColumn('home', 'integer', [ |
55
|
|
|
'after' => 'author', |
56
|
|
|
'length' => 4, |
57
|
|
|
'null' => true, |
58
|
|
|
'default' => null, |
59
|
|
|
'comment' => '(Deprecated) Whether or not the page is the home page', |
60
|
|
|
]) |
61
|
|
|
->addColumn('status', 'set', [ |
62
|
|
|
'values' => ['live', 'revision', 'disabled', 'deleted'], |
63
|
|
|
'after' => 'home', |
64
|
|
|
'null' => false, |
65
|
|
|
'default' => 'live', |
66
|
|
|
'comment' => 'The status of this page', |
67
|
|
|
]) |
68
|
|
|
->update() |
69
|
|
|
; |
70
|
|
|
|
71
|
|
|
$this->query("UPDATE pages SET status = 'deleted' WHERE is_deleted = 1"); |
72
|
|
|
$this->query("UPDATE pages SET status = 'revision' WHERE is_unlisted = 1"); |
73
|
|
|
|
74
|
|
|
$pagesTable |
75
|
|
|
->removeColumn('is_unlisted') |
76
|
|
|
->removeColumn('is_draft') |
77
|
|
|
->removeColumn('is_deleted') |
78
|
|
|
->update() |
79
|
|
|
; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|