<?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
    {
        // Cek dulu apakah tabel produk ada
        if (Schema::hasTable('produk') && Schema::hasColumn('produk', 'foto')) {
            Schema::table('produk', function (Blueprint $table) {
                $table->dropColumn('foto');
            });
        }
    }

    public function down(): void
    {
        if (Schema::hasTable('produk') && !Schema::hasColumn('produk', 'foto')) {
            Schema::table('produk', function (Blueprint $table) {
                $table->string('foto')->nullable();
            });
        }
    }
};