<?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::create('video_slides', function (Blueprint $table) {
            $table->id();
            $table->foreignId('video_id')->constrained()->cascadeOnDelete();
            $table->string('filename');
            $table->unsignedSmallInteger('position')->default(0);
            $table->timestamps();
        });

        Schema::table('videos', function (Blueprint $table) {
            $table->string('slideshow_video_path')->nullable()->after('thumbnail');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('video_slides');
        Schema::table('videos', function (Blueprint $table) {
            $table->dropColumn('slideshow_video_path');
        });
    }
};
