<?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('mime_types', function (Blueprint $table) {
            $table->id();
            $table->foreignId('account_id')->constrained('accounts')->cascadeOnDelete();
            $table->string('extension', 32)->comment('mp4, vue, jsx (without dot)');
            $table->string('mime_type', 100)->comment('video/mp4, text/javascript');
            $table->timestamps();
            $table->unique(['account_id', 'extension']);
        });

        Schema::create('apache_handlers', function (Blueprint $table) {
            $table->id();
            $table->foreignId('account_id')->constrained('accounts')->cascadeOnDelete();
            $table->string('extension', 32);
            $table->string('handler', 100)->comment('cgi-script, php-fpm, server-info');
            $table->timestamps();
            $table->unique(['account_id', 'extension']);
        });
    }

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