laravel-files/database/migrations/create_blax_filables_table....

34 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2026-04-14 08:20:55 +00:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create(config('files.table_names.filables', 'filables'), function (Blueprint $table) {
$table->id();
$table->uuid('file_id');
$table->morphs('filable');
$table->string('as')->nullable()->index();
$table->smallInteger('order')->nullable()->default(null);
$table->json('meta')->nullable();
$table->timestamps();
$table->foreign('file_id')
->references('id')
->on(config('files.table_names.files', 'files'))
->cascadeOnDelete();
$table->unique(['file_id', 'filable_type', 'filable_id', 'as'], 'filables_unique');
});
}
public function down(): void
{
Schema::dropIfExists(config('files.table_names.filables', 'filables'));
}
};