Expand profile gender options and cover country plus activity persistence.
Allow the broader gender enum and add tests for country saves and discovery event recording.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('user_profiles') || ! Schema::hasColumn('user_profiles', 'gender')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$driver = Schema::getConnection()->getDriverName();
|
||||
|
||||
if ($driver !== 'mysql') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Production/local imports may still be enum('M','F') while the app stores X
|
||||
// for "prefer not to say" / non-binary. Expand safely without rewriting rows.
|
||||
DB::statement("ALTER TABLE `user_profiles` MODIFY `gender` ENUM('M','F','X') NULL DEFAULT NULL");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('user_profiles') || ! Schema::hasColumn('user_profiles', 'gender')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$driver = Schema::getConnection()->getDriverName();
|
||||
|
||||
if ($driver !== 'mysql') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Map unsupported values before shrinking the enum.
|
||||
DB::table('user_profiles')
|
||||
->where('gender', 'X')
|
||||
->update(['gender' => null]);
|
||||
|
||||
DB::statement("ALTER TABLE `user_profiles` MODIFY `gender` ENUM('M','F') NULL DEFAULT NULL");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user