<?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('galleries', function (Blueprint $table): void {
            $table->string('sparkbooth_username')->nullable()->after('access_duration_minutes');
            $table->text('sparkbooth_password')->nullable()->after('sparkbooth_username');
            $table->string('sparkbooth_response_format', 10)->default('json')->after('sparkbooth_password');

            $table->unique('sparkbooth_username');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('galleries', function (Blueprint $table): void {
            $table->dropUnique(['sparkbooth_username']);

            $table->dropColumn([
                'sparkbooth_username',
                'sparkbooth_password',
                'sparkbooth_response_format',
            ]);
        });
    }
};
