<?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::table('events', function (Blueprint $table) {
            $table->boolean('photobooth_enabled')->default(false)->after('settings');
            $table->string('photobooth_username', 32)->nullable()->after('photobooth_enabled');
            $table->text('photobooth_password_encrypted')->nullable()->after('photobooth_username');
            $table->string('photobooth_path')->nullable()->after('photobooth_password_encrypted');
            $table->timestamp('photobooth_expires_at')->nullable()->after('photobooth_path');
            $table->string('photobooth_status', 32)->default('inactive')->after('photobooth_expires_at');
            $table->timestamp('photobooth_last_provisioned_at')->nullable()->after('photobooth_status');
            $table->timestamp('photobooth_last_deprovisioned_at')->nullable()->after('photobooth_last_provisioned_at');
            $table->json('photobooth_metadata')->nullable()->after('photobooth_last_deprovisioned_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('events', function (Blueprint $table) {
            $table->dropColumn([
                'photobooth_enabled',
                'photobooth_username',
                'photobooth_password_encrypted',
                'photobooth_path',
                'photobooth_expires_at',
                'photobooth_status',
                'photobooth_last_provisioned_at',
                'photobooth_last_deprovisioned_at',
                'photobooth_metadata',
            ]);
        });
    }
};
