<?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('workboard_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('solicitor_id')->nullable()->constrained()->cascadeOnDelete();
            $table->foreignId('workboard_category_id')->constrained()->cascadeOnDelete();
            $table->nullableMorphs('owner');
            $table->string('title');
            $table->text('description')->nullable();
            $table->timestamp('due_at')->nullable();
            $table->foreignId('claimed_by_user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamp('claimed_at')->nullable();
            $table->timestamp('completed_at')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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