<?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('hentai', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->string('title_jpn');
            $table->string('slug');
            $table->tinyInteger('episodes');
            $table->text('description');
            $table->tinyText('duration');
            $table->tinyText('status');
            $table->float('score');
            $table->string('cover_url');
            $table->integer('studios_id');
            $table->date('upload_date');
            $table->date('release_date');
            $table->timestamps();
        });

        Schema::create('episode', function (Blueprint $table) {
            $table->id();
            $table->integer('hentai_id');
            $table->integer('episode');
            $table->string('url');
            $table->string('cover_url');
            $table->tinyText('resolution');
            $table->bigInteger('view_count')->unsigned()->default(0)->index();
            $table->string('download_url')->nullable();
            $table->boolean('legacy_stream')->default(1);
            $table->timestamps();
        });

        Schema::create('studios', function (Blueprint $table) {
            $table->id();
            $table->tinyText('name');
            $table->tinyText('slug');
            $table->timestamps();
        });

        Schema::create('gallery', function (Blueprint $table) {
            $table->id();
            $table->integer('hentai_id');
            $table->integer('episode_id');
            $table->string('image_url');
            $table->string('thumbnail_url');
            $table->timestamps();
        });

        Schema::create('popular_weekly', function (Blueprint $table) {
            $table->id();
            $table->integer('episode_id');
            $table->timestamps();
        });

        Schema::create('popular_monthly', function (Blueprint $table) {
            $table->id();
            $table->integer('episode_id');
            $table->timestamps();
        });

        Schema::create('popular_daily', function (Blueprint $table) {
            $table->id();
            $table->integer('episode_id');
            $table->timestamps();
        });
    }
};
