<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('devices', function (Blueprint $table) {
            $table->uuid('id')->primary();

            // RELATION
            $table->foreignUuid('user_id')->constrained()->cascadeOnDelete();

            // DEVICE IDENTIFICATION (WICHTIG!)
            $table->string('device_id'); // eindeutige ID vom Gerät

            // PUSH TOKEN
            $table->string('push_token')->nullable(); // APNs / Firebase

            // INFO
            $table->string('platform'); // ios, android
            $table->string('device_name')->nullable();

            // STATUS
            $table->boolean('active')->default(true);

            // OPTIONAL (für später sehr wertvoll)
            $table->timestamp('last_seen')->nullable();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('devices');
    }
};
