<?php

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

class CreateBudgetItemsTable extends Migration
{
    public function up()
    {
        Schema::create('budget_items', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->string('budget_id');
            $table->string('medical_service_id');
            $table->integer('quantity')->default(1);
            $table->decimal('price', 10, 2);
            $table->decimal('subtotal', 10, 2);
            $table->text('notes')->nullable();
            $table->timestamps();

            $table->foreign('budget_id')
                  ->references('id')
                  ->on('budgets')
                  ->onDelete('cascade');

            $table->foreign('medical_service_id')
                  ->references('id')
                  ->on('medical_services')
                  ->onDelete('restrict');
        });
    }

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