-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
231 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class PageStatusConversion extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$pagesTable = $this->table('pages'); | ||
$pagesTable | ||
->addColumn('is_unlisted', 'boolean', [ | ||
'after' => 'home', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this page should be listed in the secondary navigation', | ||
]) | ||
->addColumn('is_draft', 'boolean', [ | ||
'after' => 'is_unlisted', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not the news article is a draft', | ||
]) | ||
->addColumn('is_deleted', 'boolean', [ | ||
'after' => 'is_draft', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this entry has been soft-deleted', | ||
]) | ||
->update() | ||
; | ||
|
||
$this->query("UPDATE pages SET is_deleted = 1 WHERE status != 'live';"); | ||
|
||
$pagesTable | ||
->removeColumn('parent_id') | ||
->removeColumn('home') | ||
->removeColumn('status') | ||
->update() | ||
; | ||
} | ||
|
||
public function down() | ||
{ | ||
$pagesTable = $this->table('pages'); | ||
$pagesTable | ||
->addColumn('parent_id', 'integer', [ | ||
'after' => 'id', | ||
'null' => true, | ||
'default' => null, | ||
'length' => 10, | ||
'comment' => 'The ID of the original page. If this column is set, then it is a revision', | ||
]) | ||
->addColumn('home', 'integer', [ | ||
'after' => 'author', | ||
'length' => 4, | ||
'null' => true, | ||
'default' => null, | ||
'comment' => '(Deprecated) Whether or not the page is the home page', | ||
]) | ||
->addColumn('status', 'set', [ | ||
'values' => ['live', 'revision', 'disabled', 'deleted'], | ||
'after' => 'home', | ||
'null' => false, | ||
'default' => 'live', | ||
'comment' => 'The status of this page', | ||
]) | ||
->update() | ||
; | ||
|
||
$this->query("UPDATE pages SET status = 'deleted' WHERE is_deleted = 1"); | ||
|
||
$pagesTable | ||
->removeColumn('is_unlisted') | ||
->removeColumn('is_draft') | ||
->removeColumn('is_deleted') | ||
->update() | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.