Skip to content

Commit

Permalink
change primary key to uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
imahmood committed Jan 1, 2024
1 parent ef6b541 commit 725271b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('media', function (Blueprint $table) {
$table->uuid('id')->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('media', function (Blueprint $table) {
$table->unsignedBigInteger('id')->change();
});
}
};
5 changes: 3 additions & 2 deletions src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Facades\Storage;
use Imahmood\FileStorage\Database\Factories\MediaFactory;

/**
* @property int $id
* @property string $id
* @property string $disk
* @property string|null $model_type
* @property int|null $model_id
Expand All @@ -38,7 +39,7 @@
*/
class Media extends Model
{
use HasFactory;
use HasFactory, HasUuids;

/**
* {@inheritDoc}
Expand Down

0 comments on commit 725271b

Please sign in to comment.