<?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('anime_swipes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('anime_id')->constrained()->cascadeOnDelete();
            $table->enum('direction', ['like', 'skip']);
            $table->timestamp('created_at')->useCurrent();
            $table->unique(['user_id', 'anime_id']);
            $table->index('user_id');
        });

        Schema::table('animes', function (Blueprint $table) {
            $table->text('discovery_hook')->nullable()->after('description');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('anime_swipes');
        Schema::table('animes', function (Blueprint $table) {
            $table->dropColumn('discovery_hook');
        });
    }
};
