<?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('b2b_trade_addresses', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('trade_customer_id');
            $table->string('address_1', 255);
            $table->string('address_2', 255)->nullable();
            $table->string('city', 100);
            $table->string('postcode', 20);
            $table->timestamps();

            $table->foreign('trade_customer_id')->references('id')->on('b2b_trade_customers')->onDelete('cascade');
            $table->index('trade_customer_id');
        });
    }

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