<?php

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

/**
 * Migration ini hanya berjalan jika tabel users BELUM ada.
 * Jika sudah ada (bawaan Laravel), hanya tambahkan kolom yang kurang.
 */
return new class extends Migration {
    public function up(): void
    {
        if (!Schema::hasTable('users')) {
            Schema::create('users', function (Blueprint $table) {
                $table->id();
                $table->string('name');
                $table->string('email')->unique();
                $table->string('password');
                $table->string('phone')->nullable();
                $table->string('foto')->nullable();
                $table->enum('role', ['customer', 'admin'])->default('customer');
                $table->boolean('is_active')->default(true);
                $table->timestamp('email_verified_at')->nullable();
                $table->rememberToken();
                $table->timestamps();
            });
        }
    }

    public function down(): void
    {
        // Jangan drop tabel users di sini karena mungkin dibuat migration lain
    }
};
