<?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('shop_garment_fields', function (Blueprint $table) {
            $table->id();
            $table->foreignId('shop_id')->constrained()->cascadeOnDelete();
            $table->foreignId('garment_type_id')->constrained()->cascadeOnDelete();
            $table->foreignId('measurement_field_id')->constrained()->cascadeOnDelete();
            $table->string('custom_label')->nullable(); // shop's own label, e.g. "மார்பு" instead of "Chest"
            $table->unsignedInteger('display_order')->default(0);
            $table->boolean('is_required')->default(false);
            $table->timestamps();

            $table->unique(['shop_id', 'garment_type_id', 'measurement_field_id'], 'shop_garment_field_unique');
        });
    }

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