From 2ca11d42fb623d699aa5d5d90bb264b8ef21dac7 Mon Sep 17 00:00:00 2001 From: baodev0 Date: Thu, 15 Oct 2026 08:34:42 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20migration=20uuid=20notifications=20d?= =?UTF-8?q?=C3=B9ng=20Str::orderedUuid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Str::uuid7 chỉ có từ Laravel 11, server chạy vendor cũ bị lỗi BadMethodCallException. Bỏ qua thêm cột uuid nếu lần chạy lỗi trước đã thêm. Co-Authored-By: Claude Opus 5.5 --- ...26_10_13_000005_add_uuid_to_notifications_table.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database/migrations/2026_10_13_000005_add_uuid_to_notifications_table.php b/database/migrations/2026_10_13_000005_add_uuid_to_notifications_table.php index cea56f6..5c38f53 100644 --- a/database/migrations/2026_10_13_000005_add_uuid_to_notifications_table.php +++ b/database/migrations/2026_10_13_000005_add_uuid_to_notifications_table.php @@ -10,13 +10,15 @@ return new class extends Migration { public function up(): void { - Schema::table('notifications', function (Blueprint $table) { - $table->uuid('uuid')->nullable()->after('id'); - }); + if (! Schema::hasColumn('notifications', 'uuid')) { + Schema::table('notifications', function (Blueprint $table) { + $table->uuid('uuid')->nullable()->after('id'); + }); + } DB::table('notifications')->whereNull('uuid')->orderBy('id')->chunkById(500, function ($rows) { foreach ($rows as $row) { - DB::table('notifications')->where('id', $row->id)->update(['uuid' => (string) Str::uuid7()]); + DB::table('notifications')->where('id', $row->id)->update(['uuid' => (string) Str::orderedUuid()]); } });