<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('wines', function (Blueprint $table) {
            $table->id();
            $table->integer('vintage')->comment('Wine vintage year');
            $table->foreignId('grape_variety_id')->constrained('grape_varieties')->onDelete('cascade')->comment('Primary grape variety');
            $table->string('wine_name')->comment('Name of the wine product');
            $table->enum('wine_type', ['red', 'white', 'rose'])->nullable()->comment('Wine type');
            $table->text('description')->nullable()->comment('Wine description and tasting notes');
            $table->decimal('alcohol_percentage', 5, 2)->nullable()->comment('Alcohol content percentage');
            $table->integer('bottles_produced')->nullable()->comment('Total number of bottles produced');
            $table->integer('bottles_in_stock')->default(0)->comment('Current bottles in stock');
            $table->decimal('price_per_bottle', 8, 2)->nullable()->comment('Price per bottle');
            $table->decimal('bottle_volume', 5, 3)->default(0.75)->comment('Bottle volume in liters');
            $table->date('production_date')->nullable()->comment('Wine production date');
            $table->date('bottling_date')->nullable()->comment('Bottling date');
            $table->enum('status', ['in_production', 'aging', 'ready', 'sold_out'])->default('in_production')->comment('Wine status');
            $table->string('image_url')->nullable()->comment('Image URL for catalog display');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wines');
    }
};
