<?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
    {
        if (! Schema::hasTable('activity_attachment_requirements')) {
            Schema::create('activity_attachment_requirements', function (Blueprint $table) {
                $table->id();
                $table->foreignId('business_id')->index();
                $table->string('activity_type');
                $table->string('outcome')->nullable();
                $table->boolean('required')->default(true);
                $table->timestamps();
            });
        }
        Schema::table('activity_attachment_requirements', function (Blueprint $table) {
            $table->unique(['business_id', 'activity_type', 'outcome'], 'act_attach_requirement_unique');
        });
    }

    public function down(): void { Schema::dropIfExists('activity_attachment_requirements'); }
};
