<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCurtainDoorDetailsTable extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('curtain_door_details')) {
            Schema::create('curtain_door_details', function (Blueprint $table) {
                $table->id();
                $table->unsignedBigInteger('curtain_id');
                $table->string('label')->nullable();
                $table->unsignedInteger('door_count')->default(1);
                $table->string('material_type', 30)->default('fabric');
                $table->decimal('meterage', 10, 2)->default(0);
                $table->index(['curtain_id', 'material_type']);
            });
        }
    }

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