<?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
    {
        // Video Data: some video assets have additional data associated with them
        Schema::create('video_datas', function (Blueprint $table) {
            $table->id();
            $table->foreignId('video_id'); // video this data belongs to
            $table->enum('media_type', ['text', 'image', 'video', 'audio', 'video_subtitle', 'text_overlay']); // what kind of data is this?
            $table->enum('source', ['generated', 'uploaded', 'other']); // where did this data come from?
            $table->string('source_name')->nullable(); // name of source
            $table->string('key', 255); // identifier for data
            $table->string('value')->nullable(); // if data is a id or value or some form of identifier
            $table->jsonb('payload')->nullable(); // if data contains additional information like api response, etc.
            $table->string('url')->nullable(); // if data contains a url
            $table->timestamps();

            $table->foreign('video_id')->references('id')->on('videos')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('video_datas');
    }
};
