<?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('task_submission_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('task_submission_id')->constrained('task_submissions')->cascadeOnDelete();
            $table->unsignedSmallInteger('sort_order')->default(0);
            $table->string('line_type', 32)->default('metric');
            $table->string('line_label', 128);
            $table->unsignedTinyInteger('account_number')->nullable();
            $table->unsignedInteger('quantity')->nullable();
            $table->string('quantity_unit', 32)->nullable();
            $table->string('quantity_screenshot_path')->nullable();
            $table->string('quantity_screenshot_name')->nullable();
            $table->unsignedInteger('total_quantity')->nullable();
            $table->string('total_screenshot_path')->nullable();
            $table->string('total_screenshot_name')->nullable();
            $table->unsignedInteger('pending_quantity')->nullable();
            $table->string('pending_screenshot_path')->nullable();
            $table->string('pending_screenshot_name')->nullable();
            $table->unsignedInteger('done_quantity')->nullable();
            $table->string('done_screenshot_path')->nullable();
            $table->string('done_screenshot_name')->nullable();
            $table->timestamps();

            $table->index(['task_submission_id', 'sort_order']);
        });
    }

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