<?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('customers', function (Blueprint $table) {
            $table->id();

            // AIK Digital identifiers
            $table->string('open_id')->unique()->comment('UUID from AIK Digital iframe — primary customer identifier');
            $table->string('union_id')->nullable()->comment('Cross-platform union identifier from AIK Digital');

            // Customer profile (from inquireUserInfo response)
            $table->string('msisdn', 20)->comment('Mobile number in international format e.g. 923001234567');
            $table->string('name');
            $table->string('email')->nullable();
            $table->string('dob', 20)->nullable()->comment('DD-MM-YYYY format from AIK Digital');
            $table->string('cnic', 20)->nullable()->comment('XXXXX-XXXXXXX-X format');
            $table->string('gender', 10)->nullable();

            $table->timestamps();

            $table->index('msisdn');
            $table->index('cnic');
        });
    }

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