<?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('branches', function (Blueprint $table) {
            $table->id();
            $table->string('unique_code')->nullable()->unique();

            $table->json('name');
            $table->json('address')->nullable();

            $table->string('region', 2)->index();
            $table->foreignId('province_id')->nullable()->constrained('provinces')->onDelete('restrict');

            $table->json('phone_numbers')->nullable();

            $table->string('billing_username')->nullable();
            $table->string('billing_password')->nullable();

            $table->string('billing_swift_username')->nullable();
            $table->string('billing_swift_password')->nullable();

            $table->string('billing_visa_master_username')->nullable();
            $table->string('billing_visa_master_password')->nullable();

            $table->string('billing_sber_username')->nullable();
            $table->string('billing_sber_password')->nullable();

            $table->boolean('active')->default(true);
            $table->timestamps();
        });
    }

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