fix: migration uuid notifications dùng Str::orderedUuid

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 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-15 08:34:42 +07:00
co-authored by Claude Opus 5.5
parent 725edb11a3
commit 2ca11d42fb
@@ -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()]);
}
});