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:
co-authored by
Claude Opus 5.5
parent
725edb11a3
commit
2ca11d42fb
@@ -10,13 +10,15 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('notifications', function (Blueprint $table) {
|
if (! Schema::hasColumn('notifications', 'uuid')) {
|
||||||
$table->uuid('uuid')->nullable()->after('id');
|
Schema::table('notifications', function (Blueprint $table) {
|
||||||
});
|
$table->uuid('uuid')->nullable()->after('id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
DB::table('notifications')->whereNull('uuid')->orderBy('id')->chunkById(500, function ($rows) {
|
DB::table('notifications')->whereNull('uuid')->orderBy('id')->chunkById(500, function ($rows) {
|
||||||
foreach ($rows as $row) {
|
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()]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user