<?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('video_sources', function (Blueprint $table) {
            $table->id();
            $table->foreignId('episode_id')->constrained('episodes')->cascadeOnDelete();
            $table->string('label', 120)->default('');
            $table->text('url');
            $table->enum('type', ['mp4', 'hls', 'embed'])->default('mp4');
            $table->string('quality', 20)->default('');
            $table->string('translator_id', 60)->nullable();
            $table->unsignedSmallInteger('sort_order')->default(0);
            $table->boolean('is_default')->default(false);
            $table->string('source', 30)->default('animecix');
            $table->timestamps();

            $table->index('episode_id');
        });
    }

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