<?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::create('user_server_permissions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('server_resource_id')->constrained()->cascadeOnDelete();
            $table->boolean('can_ssh')->default(false);
            $table->boolean('can_sftp')->default(false);
            $table->boolean('can_rdp')->default(false);
            $table->timestamps();

            $table->unique(['user_id', 'server_resource_id']);
        });
    }

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