<?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('produks', function (Blueprint $table) {
            $table->id();
            $table->foreignId('kategori_produk_id')->nullable()->references('id')->on('kategori_produks')->onUpdate('cascade')->onDelete('cascade');
            $table->string('kode_produk')->nullable();
            $table->string('nama_produk')->nullable();
            $table->text('varian_produk')->nullable();
            $table->longText('deskripsi_produk')->nullable();
            $table->bigInteger('harga_produk')->nullable();
            $table->tinyInteger('stok_produk')->nullable();
            $table->enum('tersedia', [0, 1])->default(1)->comment('0=tidak,1=iya');
            $table->string('gambar_produk')->nullable();
            $table->tinyInteger('urutan')->nullable();

            $table->unsignedBigInteger("updated_by")->nullable();
            $table->unsignedBigInteger("created_by")->nullable();
            $table->unsignedBigInteger("deleted_by")->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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