<?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('product', function (Blueprint $table) {
            $table->id('produk_id');
            $table->unsignedBigInteger('kategori_id')->nullable();
            $table->string('nama_produk');
            $table->integer('harga');
            $table->integer('stok');
            $table->date('tanggal_kadaluarsa')->nullable(); 
            $table->timestamps();

            $table->foreign('kategori_id')
                ->references('kategori_id')
                ->on('kategori')
                ->onDelete('set null')
                ->onUpdate('cascade');
        });
    }

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