<?php

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

return new class extends Migration
{
    /**
     * Tambahan data administrasi pelanggan/instansi.
     */
    public function up(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            if (!Schema::hasColumn('customers', 'contact_person')) {
                $table->string('contact_person', 100)->nullable()->after('member_type');
            }

            if (!Schema::hasColumn('customers', 'npwp')) {
                $table->string('npwp', 50)->nullable()->after('email');
            }
        });
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            if (Schema::hasColumn('customers', 'contact_person')) {
                $table->dropColumn('contact_person');
            }

            if (Schema::hasColumn('customers', 'npwp')) {
                $table->dropColumn('npwp');
            }
        });
    }
};
