<?php

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

class CreateAddressesTable extends Migration
{
    public function up()
    {

        Schema::create('addresses', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger('client_id');
            $table->foreign('client_id')->references('id')->on('clients')->onUpdate('cascade')->onDelete('cascade');

            $table->unsignedBigInteger('country_id');
            $table->foreign('country_id')->nullable()->references('id')->on('countries')->onUpdate('cascade')->onDelete('cascade');

            $table->unsignedBigInteger('region_id')->nullable();
            $table->foreign('region_id')->nullable()->references('id')->on('regions')->onUpdate('cascade')->onDelete('cascade');

            $table->string('lat')->nullable();
            $table->string('long')->nullable();

            $table->string('block')->nullable();
            $table->string('road')->nullable();
            $table->string('building')->nullable();
            $table->string('apartment')->nullable();
            $table->text('additional_directions')->nullable();
            $table->timestamps();
        });
    }

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