<?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::table('stage_academy_course_videos', function (Blueprint $table) {
            if (Schema::hasColumn('stage_academy_course_videos', 'duration_seconds')) {
                return;
            }

            $table->unsignedInteger('duration_seconds')->nullable()->after('vimeo_url');
        });
    }

    public function down(): void
    {
        Schema::table('stage_academy_course_videos', function (Blueprint $table) {
            if (! Schema::hasColumn('stage_academy_course_videos', 'duration_seconds')) {
                return;
            }

            $table->dropColumn('duration_seconds');
        });
    }
};
