-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- .hide class would get overridden by custom.css - Stock editing for existing shop stock would not update correctly due to missing keys in the form - Removed a unique key constraint in an earlier table that was occasionally causing migration issues - Made character and character image deletion more thorough to avoid problems with deleting apparently-unused features and currencies - Was not able to grant character-held only currencies to characters Miscellaneous - Added a script to clear any character features and currencies on deleted characters, as well as delete their images
- Loading branch information
Showing
8 changed files
with
139 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
use DB; | ||
|
||
use App\Models\Character\Character; | ||
use App\Models\Character\CharacterCurrency; | ||
use App\Models\Character\CharacterFeature; | ||
use App\Models\Character\CharacterImage; | ||
|
||
class ClearDeletedCharacterAttachments extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'clear-deleted-character-attachments'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Clears any currently remaining character attachments (features and currency) so that they can be deleted.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
// Get deleted character IDs | ||
$deletedCharacterIds = DB::table('characters')->whereNotNull('deleted_at')->pluck('id'); | ||
|
||
// Delete their held currencies | ||
CharacterCurrency::whereIn('character_id', $deletedCharacterIds)->delete(); | ||
|
||
// Delete their character images | ||
CharacterImage::whereIn('character_id', $deletedCharacterIds)->delete(); | ||
|
||
// Get all deleted character images | ||
$deletedImageIds = DB::table('character_images')->whereNotNull('deleted_at')->pluck('id'); | ||
|
||
// Delete their features | ||
CharacterFeature::whereIn('character_image_id', $deletedImageIds)->delete(); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
database/migrations/2020_04_25_114747_drop_log_foreign_keys.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,37 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class DropLogForeignKeys extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
// This will drop the currency log foreign keys, so that currencies can be deleted without issue | ||
// even if a log exists for it | ||
Schema::table('currencies_log', function(Blueprint $table) { | ||
$table->dropForeign('banks_log_currency_id_foreign'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
// This is not actually a very accurate opposite of the above, | ||
// as the old index was created when the table was called banks, | ||
// and this will generate a different index name | ||
Schema::table('currencies_log', function(Blueprint $table) { | ||
$table->foreign('currency_id')->references('id')->on('currencies'); | ||
}); | ||
} | ||
} |
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