<?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::table('stok_akhir', function (Blueprint $table) {
            // 1. Rename id_stok menjadi id_produk
            $table->renameColumn('id_stok', 'id_produk');
            
            // 2. Hapus status UNIQUE pada jenis_barang agar bisa simpan banyak produk
            // Kita gunakan dropUnique(['nama_kolom'])
            $table->dropUnique(['jenis_barang']); 
            
            // 3. Pastikan panjang id_produk cukup (opsional, jika ingin memperpanjang)
            // $table->string('id_produk', 10)->change();
        });
    }

    public function down(): void
    {
        Schema::table('stok_akhir', function (Blueprint $table) {
            $table->renameColumn('id_produk', 'id_stok');
            $table->unique('jenis_barang');
        });
    }
};