<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('events', function (Blueprint $table) {
            $table->integer('id', true); // int NOT NULL AUTO_INCREMENT PRIMARY KEY
            $table->date('date')->nullable()->index('idx_date');
            $table->time('time')->nullable();
            $table->string('name', 1024)->nullable();
            $table->integer('place_id')->nullable()->index('idx_placeid');
            $table->binary('description')->nullable(); // blob
            $table->tinyInteger('archived')->default(0)->index('idx_archived');
            $table->string('image', 128)->nullable();
            $table->integer('price')->nullable();
            $table->string('link', 255)->nullable();

            // Поля дат с дефолтными значениями
            $table->dateTime('updated_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->dateTime('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->dateTime('deleted_at')->nullable();

            // Настройка движка и кодировки (опционально, если нужно строго как в SQL)
            $table->engine = 'InnoDB';
            // $table->charset = 'utf8mb3';
        });
    }

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