41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
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::create('attachments', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('thread_id')->nullable()->constrained('threads')->nullOnDelete();
|
|
$table->foreignId('post_id')->nullable()->constrained('posts')->nullOnDelete();
|
|
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
|
|
$table->string('disk', 50)->default('local');
|
|
$table->string('path');
|
|
$table->string('original_name');
|
|
$table->string('extension', 30)->nullable();
|
|
$table->string('mime_type', 150);
|
|
$table->unsignedBigInteger('size_bytes');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->index('thread_id', 'idx_attachments_thread_id');
|
|
$table->index('post_id', 'idx_attachments_post_id');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('attachments');
|
|
}
|
|
};
|