<?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('events', function (Blueprint $table) {
            $table->uuid('id')->primary();

            $table->uuid('user_id');

            $table->string('title');
            $table->string('color')->nullable();
            $table->string('google_event_id')->nullable();

            $table->timestamp('starts_at');
            $table->timestamp('ends_at')->nullable();
            $table->boolean('is_all_day')->default(false);

            $table->date('start_date')->nullable();
            $table->date('end_date')->nullable();

            $table->text('notes')->nullable();
            $table->json('reminders')->nullable();

            $table->string('recurrence')->nullable();
            $table->date('recurrence_end_date')->nullable();

            $table->json('exceptions')->nullable();
            $table->json('participants')->nullable();
            $table->timestamps();

            $table->index('user_id');
            $table->index('starts_at');
            $table->index('google_event_id');
        });
    }

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