<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::dropIfExists('cutting_result_prices');
    }

    public function down(): void
    {
        Schema::create('cutting_result_prices', function ($table) {
            $table->id();
            $table->foreignId('cutting_id')->constrained()->restrictOnDelete();
            $table->foreignId('product_variant_id')->constrained()->restrictOnDelete();
            $table->string('price_type');
            $table->unsignedInteger('price')->default(0);
            $table->unsignedInteger('cost_per_unit')->default(0);
            $table->timestamps();
            $table->unique(['cutting_id', 'product_variant_id', 'price_type'], 'cutting_result_prices_unique');
        });
    }
};
