<?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('photos', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('event_id');
            $table->unsignedBigInteger('emotion_id');
            $table->unsignedBigInteger('task_id')->nullable();
            $table->string('guest_name');
            $table->string('file_path');
            $table->string('thumbnail_path');
            $table->integer('likes_count')->default(0);
            $table->boolean('is_featured')->default(false);
            $table->json('metadata')->nullable();
            $table->timestamps();
        });

        Schema::create('photo_likes', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('photo_id');
            $table->string('guest_name');
            $table->string('ip_address', 45)->nullable();
            $table->timestamp('created_at')->useCurrent();
            $table->unique(['photo_id','guest_name','ip_address']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('photo_likes');
        Schema::dropIfExists('photos');
    }
};

