From 11491e07aa7a885c50f82022ac661beceb1aa8ce Mon Sep 17 00:00:00 2001 From: sky121113 Date: Mon, 12 Jan 2026 13:11:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E7=9A=84=20add=5Fusername=5Fto=5Fusers=5Ftable=20migration=20?= =?UTF-8?q?=E6=AA=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._01_12_031836_add_username_to_users_table.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/database/migrations/2026_01_12_031836_add_username_to_users_table.php b/database/migrations/2026_01_12_031836_add_username_to_users_table.php index 5773e07..775c9fc 100644 --- a/database/migrations/2026_01_12_031836_add_username_to_users_table.php +++ b/database/migrations/2026_01_12_031836_add_username_to_users_table.php @@ -11,9 +11,11 @@ return new class extends Migration */ public function up(): void { - Schema::table('users', function (Blueprint $table) { - // - }); + if (!Schema::hasColumn('users', 'username')) { + Schema::table('users', function (Blueprint $table) { + $table->string('username')->unique()->nullable()->after('id'); + }); + } } /** @@ -21,8 +23,10 @@ return new class extends Migration */ public function down(): void { - Schema::table('users', function (Blueprint $table) { - // - }); + if (Schema::hasColumn('users', 'username')) { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('username'); + }); + } } };