<?php

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

class CreateAddressbookTable extends Migration
{
    public function up()
    {
        Schema::create('addressbook', function (Blueprint $table) {
            $table->id('Sno'); // Auto-incrementing ID
            $table->string('user_id'); // User ID with specific format
            $table->string('Floor')->nullable();
            $table->string('Caddress'); // Complete address
            $table->string('HTReach')->nullable(); // How to reach the address
            $table->string('Type')->nullable(); // Type of address (home, office, etc.)
            $table->text('Dinstruction')->nullable(); // Directions
            $table->text('Ainstruction')->nullable(); // Additional instructions
            $table->decimal('Latitude', 10, 7)->nullable(); // Latitude
            $table->decimal('Longitude', 10, 7)->nullable(); // Longitude
            $table->string('voice_path')->nullable(); // Path for voice note
            $table->timestamps(); // created_at and updated_at
             $table->foreign('user_id')->references('user_id')->on('users')->onDelete('cascade');
        });
    }

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

