<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('locations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->decimal('latitude', 10, 7);
            $table->decimal('longitude', 10, 7);
            $table->tinyInteger('battery_level')->nullable(); // 0-100
            $table->string('activity_type')->nullable(); // still, walking, driving, etc.
            $table->boolean('is_moving')->default(false);
            $table->timestamp('recorded_at')->nullable(); // jab phone ne record kiya
            $table->timestamps(); // jab server ne save kiya
        });
    }

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