<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Enums\ModuleType;
use App\Enums\AttachmentContentType;

return new class extends Migration {
  /**
   * Run the migrations.
   */
  public function up(): void
  {
    Schema::create('attachments', function (Blueprint $table) {
      $table->id();
      $table->foreignId('transaction_id')->nullable()->constrained('transactions');
      $table->foreignId('payment_id')->nullable()->constrained('payments');
      $table->string('module_type')->default(ModuleType::Transaction)->index();
      $table->string('type')->default(AttachmentContentType::Image)->index();
      $table->string('label');
      $table->longText('value');
      $table->longText('description')->nullable();
      $table->string('path');
      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   */
  public function down(): void
  {
    Schema::dropIfExists('attachments');
  }
};
