-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(demos): add missing/dnm demoskill subtypes
- Loading branch information
1 parent
f19ad91
commit 6725b9f
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
php-classes/Slate/CBL/Demonstrations/DidNotMeetDemonstrationSkill.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,9 @@ | ||
<?php | ||
|
||
namespace Slate\CBL\Demonstrations; | ||
|
||
|
||
class DidNotMeetDemonstrationSkill extends DemonstrationSkill | ||
{ | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
php-classes/Slate/CBL/Demonstrations/MissingDemonstrationSkill.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,9 @@ | ||
<?php | ||
|
||
namespace Slate\CBL\Demonstrations; | ||
|
||
|
||
class MissingDemonstrationSkill extends DemonstrationSkill | ||
{ | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
php-migrations/Slate/CBL/Demonstrations/20210328_demoskill-subclass-dnm.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,23 @@ | ||
<?php | ||
|
||
namespace Slate\CBL\Demonstrations; | ||
|
||
|
||
$tableName = DemonstrationSkill::$tableName; | ||
$historyTableName = DemonstrationSkill::getHistoryTableName(); | ||
|
||
// skip if table doesn't exist | ||
if (!static::tableExists($tableName)) { | ||
printf("Skipping migration because table `%s` does not yet exist\n", $tableName); | ||
return static::STATUS_SKIPPED; | ||
} | ||
|
||
// skip if Class column already contains DidNotMeet subclass | ||
if (static::hasColumnEnumValue($tableName, 'Class', DidNotMeetDemonstrationSkill::class)) { | ||
printf("Skipping migration because column `%s`.`Class` already has value '%s'\n", $tableName, DidNotMeetDemonstrationSkill::class); | ||
return static::STATUS_SKIPPED; | ||
} | ||
|
||
// add new Class value | ||
static::addColumnEnumValue($tableName, 'Class', DidNotMeetDemonstrationSkill::class); | ||
static::addColumnEnumValue($historyTableName, 'Class', DidNotMeetDemonstrationSkill::class); |
39 changes: 39 additions & 0 deletions
39
php-migrations/Slate/CBL/Demonstrations/20210328_demoskill-subclass-missing.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,39 @@ | ||
<?php | ||
|
||
namespace Slate\CBL\Demonstrations; | ||
|
||
use DB; | ||
|
||
|
||
$tableName = DemonstrationSkill::$tableName; | ||
$historyTableName = DemonstrationSkill::getHistoryTableName(); | ||
|
||
// skip if table doesn't exist | ||
if (!static::tableExists($tableName)) { | ||
printf("Skipping migration because table `%s` does not yet exist\n", $tableName); | ||
return static::STATUS_SKIPPED; | ||
} | ||
|
||
// skip if Class column already contains Missing subclass | ||
if (static::hasColumnEnumValue($tableName, 'Class', MissingDemonstrationSkill::class)) { | ||
printf("Skipping migration because column `%s`.`Class` already has value '%s'\n", $tableName, MissingDemonstrationSkill::class); | ||
return static::STATUS_SKIPPED; | ||
} | ||
|
||
// add new Class value | ||
static::addColumnEnumValue($tableName, 'Class', MissingDemonstrationSkill::class); | ||
static::addColumnEnumValue($historyTableName, 'Class', MissingDemonstrationSkill::class); | ||
|
||
// migrate legacy missing demonstrations | ||
DB::nonQuery( | ||
'UPDATE `%s` SET Class = "%s", DemonstratedLevel = NULL WHERE Class = "%s" AND DemonstratedLevel = 0', | ||
[ | ||
$tableName, | ||
DB::escape(MissingDemonstrationSkill::class), | ||
DB::escape(DemonstrationSkill::class) | ||
] | ||
); | ||
printf( | ||
"Updated %u DemonstrationSkill records with Rating = 0 to MissingDemonstrationSkill class\n", | ||
DB::affectedRows() | ||
); |