-
-
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.
Update Server model to new Query Builder
- In addition to migrating to the new Query Builder, the Server model has gotten some new columns allowing us to classify servers based on their purpose. e.g. Match server vs replay server - The form view for Server models have also been updated to allow edits for server types.
- Loading branch information
Showing
5 changed files
with
350 additions
and
82 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
73 changes: 73 additions & 0 deletions
73
migrations/20180211020823_server_status_column_conversation.php
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,73 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class ServerStatusColumnConversation extends AbstractMigration | ||
{ | ||
public function up() | ||
{ | ||
$serversTable = $this->table('servers'); | ||
$serversTable | ||
->addColumn('is_official_server', 'boolean', [ | ||
'after' => 'updated', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this server is capable of hosting official matches', | ||
]) | ||
->addColumn('is_replay_server', 'boolean', [ | ||
'after' => 'is_official_server', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this server is dedicated to serving replays of matches', | ||
]) | ||
->addColumn('is_inactive', 'boolean', [ | ||
'after' => 'is_replay_server', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this server is no longer active but still required for historical purposes', | ||
|
||
]) | ||
->addColumn('is_deleted', 'boolean', [ | ||
'after' => 'is_inactive', | ||
'null' => false, | ||
'default' => false, | ||
'comment' => 'Whether or not this server has been soft deleted', | ||
]) | ||
->update() | ||
; | ||
|
||
// BZiON 0.10.x and below required that you soft deleted servers so they'd no longer appear on the server list. | ||
// For this reason and because Leagues United is the only known installation, we'll be assuming that deleted | ||
// servers were just meant to be marked as "inactive." | ||
$this->query("UPDATE servers SET is_inactive = 1 WHERE status = 'deleted';"); | ||
|
||
$serversTable | ||
->removeColumn('status') | ||
->update() | ||
; | ||
} | ||
|
||
public function down() | ||
{ | ||
$serversTable = $this->table('servers'); | ||
$serversTable | ||
->addColumn('status', 'set', [ | ||
'values' => ['active', 'disabled', 'deleted'], | ||
'null' => false, | ||
'default' => 'active', | ||
'comment' => 'The status of the server relative to BZiON', | ||
]) | ||
->update() | ||
; | ||
|
||
$this->query("UPDATE servers SET status = 'deleted' WHERE is_inactive = 1;"); | ||
|
||
$serversTable | ||
->removeColumn('is_official_server') | ||
->removeColumn('is_replay_server') | ||
->removeColumn('is_inactive') | ||
->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
Oops, something went wrong.