<?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('mobile_error_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->nullable()->constrained()->onDelete('set null');
            $table->string('error_type')->default('RuntimeError');
            $table->text('message');
            $table->longText('stack_trace')->nullable();
            $table->string('platform')->nullable();
            $table->string('app_version')->nullable();
            $table->json('device_info')->nullable();
            $table->timestamp('occurred_at')->useCurrent();
        });
    }

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