34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
|
|
<?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'));
|
||
|
|
}
|
||
|
|
};
|