<?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('keranjang_items', function (Blueprint $table) {
            // Tambah kolom baru (nullable dulu)
            $table->foreignId('produk_varian_id')->nullable()->after('id_produk')->constrained('produk_varians')->onDelete('cascade');
        });
    }

    public function down(): void
    {
        Schema::table('keranjang_items', function (Blueprint $table) {
            $table->dropForeign(['produk_varian_id']);
            $table->dropColumn('produk_varian_id');
        });
    }
};