<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('customers', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('entity_type')->default('CUSTOMER');
            $table->bigInteger('created_time');
            $table->string('name');
            $table->string('country', 5)->nullable();
            $table->string('state', 50)->nullable();
            $table->string('city', 100)->nullable();
            $table->string('address')->nullable();
            $table->string('address2')->nullable();
            $table->string('zip', 20)->nullable();
            $table->string('phone', 20)->nullable();
            $table->string('email')->unique();
            $table->string('title')->nullable();
            $table->uuid('tenant_id');
            $table->uuid('external_id')->nullable();
            $table->integer('version')->default(1);
            $table->json('additional_info')->nullable();
            $table->longText('country_xid')->nullable();
            $table->longText('state_xid')->nullable();
            $table->longText('city_xid')->nullable();

            $table->timestamps();

            // $table->foreign('tenant_id')->references('id')->on('tenants');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('customers');
    }
};
