<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * MENGAPA MIGRATION INI DIBUAT:
 * Sprint 2.1 Storefront memerlukan:
 *   - Logo mitra untuk ditampilkan di card mitra
 *   - Jam buka/tutup untuk menampilkan badge "Buka"/"Tutup" per mitra
 *
 * Semua kolom ADDITIVE dan NULLABLE:
 *   - Data mitra lama tidak terpengaruh
 *   - logo = null → tampilkan avatar inisial nama
 *   - open_time = null, close_time = null → mitra dianggap selalu buka (jika is_active=true)
 *
 * Format open_time / close_time: TIME (HH:MM:SS), contoh '08:00:00'
 * Logika buka/tutup dihitung di aplikasi (bukan di database).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('partners', function (Blueprint $table) {
            $table->string('logo')->nullable()->after('name');
            $table->time('open_time')->nullable()->after('is_active');
            $table->time('close_time')->nullable()->after('open_time');
        });
    }

    public function down(): void
    {
        Schema::table('partners', function (Blueprint $table) {
            $table->dropColumn(['logo', 'open_time', 'close_time']);
        });
    }
};
