<?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::create('portal_owners', function (Blueprint $t) {
            $t->bigIncrements('id');
            $t->unsignedInteger('business_id')->index();
            $t->string('name');
            $t->string('phone', 32)->nullable()->unique();
            $t->string('email')->nullable()->unique();
            // Bcrypt; null for OTP/magic-only accounts.
            $t->string('password')->nullable();
            $t->boolean('is_active')->default(true);
            $t->timestamp('last_login_at')->nullable();
            $t->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('portal_owners');
    }
};
