<?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('posts', function (Blueprint $table) {
            $table->id();
            $table->enum('tipe', ['berita', 'pengumuman'])->default('berita');
            $table->string('judul');
            $table->string('slug')->unique();
            $table->string('foto')->nullable();
            $table->longText('isi');
            $table->date('tanggal');
            $table->string('penulis')->nullable();
            $table->timestamps();

            $table->index('tipe');
            $table->index('tanggal');
            $table->index('slug');
        });
    }

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