rename shirt size keys G to F

This commit is contained in:
Xu 2023-10-25 18:18:41 +02:00 committed by Igor Scheller
parent 9ffe739b24
commit 185b7e3fb6
2 changed files with 54 additions and 4 deletions

View File

@ -348,13 +348,13 @@ return [
// To disable a t-shirt size in the config.php, you can set its value to null // To disable a t-shirt size in the config.php, you can set its value to null
'tshirt_sizes' => [ 'tshirt_sizes' => [
'S' => 'Small Straight-Cut', 'S' => 'Small Straight-Cut',
'S-G' => 'Small Fitted-Cut', 'S-F' => 'Small Fitted-Cut',
'M' => 'Medium Straight-Cut', 'M' => 'Medium Straight-Cut',
'M-G' => 'Medium Fitted-Cut', 'M-F' => 'Medium Fitted-Cut',
'L' => 'Large Straight-Cut', 'L' => 'Large Straight-Cut',
'L-G' => 'Large Fitted-Cut', 'L-F' => 'Large Fitted-Cut',
'XL' => 'XLarge Straight-Cut', 'XL' => 'XLarge Straight-Cut',
'XL-G' => 'XLarge Fitted-Cut', 'XL-F' => 'XLarge Fitted-Cut',
'2XL' => '2XLarge Straight-Cut', '2XL' => '2XLarge Straight-Cut',
'3XL' => '3XLarge Straight-Cut', '3XL' => '3XLarge Straight-Cut',
'4XL' => '4XLarge Straight-Cut', '4XL' => '4XLarge Straight-Cut',

View File

@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
class DegenderShirtSizes extends Migration
{
/** @var string[] */
protected array $sizes = [
'S-G' => 'S-F',
'M-G' => 'M-F',
'L-G' => 'L-F',
'XL-G' => 'XL-F',
];
/**
* Run the migration
*/
public function up(): void
{
$this->migrate($this->sizes);
}
/**
* Reverse the migration
*/
public function down(): void
{
$this->migrate(array_flip($this->sizes));
}
/**
* @param string[] $sizes
*/
private function migrate(array $sizes): void
{
$connection = $this->schema->getConnection();
foreach ($sizes as $from => $to) {
$connection
->table('users_personal_data')
->where('shirt_size', $from)
->update([
'shirt_size' => $to,
]);
}
}
}