Skip to content

Commit 725271b

Browse files
committed
change primary key to uuid
1 parent ef6b541 commit 725271b

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Support\Facades\Schema;
7+
8+
return new class extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*/
13+
public function up(): void
14+
{
15+
Schema::table('media', function (Blueprint $table) {
16+
$table->uuid('id')->change();
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*/
23+
public function down(): void
24+
{
25+
Schema::table('media', function (Blueprint $table) {
26+
$table->unsignedBigInteger('id')->change();
27+
});
28+
}
29+
};

src/Models/Media.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
use Illuminate\Contracts\Filesystem\Filesystem;
77
use Illuminate\Database\Eloquent\Casts\Attribute;
8+
use Illuminate\Database\Eloquent\Concerns\HasUuids;
89
use Illuminate\Database\Eloquent\Factories\HasFactory;
910
use Illuminate\Database\Eloquent\Model;
1011
use Illuminate\Database\Eloquent\Relations\MorphTo;
1112
use Illuminate\Support\Facades\Storage;
1213
use Imahmood\FileStorage\Database\Factories\MediaFactory;
1314

1415
/**
15-
* @property int $id
16+
* @property string $id
1617
* @property string $disk
1718
* @property string|null $model_type
1819
* @property int|null $model_id
@@ -38,7 +39,7 @@
3839
*/
3940
class Media extends Model
4041
{
41-
use HasFactory;
42+
use HasFactory, HasUuids;
4243

4344
/**
4445
* {@inheritDoc}

0 commit comments

Comments
 (0)