<?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::table('deals', function (Blueprint $table) {
            $table->string('trade_type', 30)->nullable()->after('comments');
            $table->foreignId('document_template_id')->nullable()->after('trade_type')->constrained('document_templates')->nullOnDelete();
            $table->date('valid_until')->nullable()->after('document_template_id');
        });
    }

    public function down(): void
    {
        Schema::table('deals', function (Blueprint $table) {
            $table->dropConstrainedForeignId('document_template_id');
            $table->dropColumn(['trade_type', 'valid_until']);
        });
    }
};
