<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('video_views', function (Blueprint $table) {
            $table->string('device_id', 64)->nullable()->after('user_agent');
            $table->index(['video_id', 'device_id']);
        });
    }

    public function down(): void
    {
        Schema::table('video_views', function (Blueprint $table) {
            $table->dropIndex(['video_id', 'device_id']);
            $table->dropColumn('device_id');
        });
    }
};
