vernova/database/migrations/2024_01_01_000023_create_attachments_table.php
2026-07-26 19:58:27 +03:30

34 lines
1.1 KiB
PHP

<?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('attachments', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->morphs('attachable');
$table->string('file_name');
$table->string('file_path');
$table->string('mime_type')->nullable();
$table->unsignedBigInteger('file_size')->default(0);
$table->string('category')->default('receipt'); // receipt, document, photo, other
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['tenant_id', 'attachable_type', 'attachable_id']);
});
}
public function down(): void
{
Schema::dropIfExists('attachments');
}
};