<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAddressesAndRidersTable extends Migration {
    public function up(){
        Schema::create('addresses', function(Blueprint $table){
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->enum('label',['Home','Work','Other'])->default('Home');
            $table->string('line1');
            $table->string('line2')->nullable();
            $table->string('city')->nullable();
            $table->string('state')->nullable();
            $table->string('pincode')->nullable();
            $table->decimal('lat',10,7)->nullable();
            $table->decimal('lng',10,7)->nullable();
            $table->text('instructions')->nullable();
            $table->timestamps();
        });

        Schema::create('riders', function(Blueprint $table){
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->string('vehicle_type')->nullable();
            $table->enum('status',['available','busy','offline'])->default('available');
            $table->decimal('current_lat',10,7)->nullable();
            $table->decimal('current_lng',10,7)->nullable();
            $table->timestamps();
        });
    }
    public function down(){
        Schema::dropIfExists('riders');
        Schema::dropIfExists('addresses');
    }
}
