Add migration to fix NULL last_username_change values and enforce default 0

This commit is contained in:
root
2026-06-08 18:11:32 +02:00
parent 4ba236249d
commit 9bb2e4246b
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
DB::table('users')
->whereNull('last_username_change')
->orWhere('last_username_change', 0)
->update(['last_username_change' => 0]);
Schema::table('users', function (Blueprint $table) {
$table->integer('last_username_change')->default(0)->change();
});
}
public function down(): void
{
// Cannot reliably revert default and data changes
}
};