<?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('kylin_notifications', function (Blueprint $table) {
            $table->id();
            $table->string('type', 50)->comment('类型:system,sms,email,wechat');
            $table->string('title', 200)->comment('标题');
            $table->text('content')->comment('内容');
            $table->string('notifiable_type', 125)->nullable();
            $table->unsignedBigInteger('notifiable_id')->nullable();
            $table->unsignedBigInteger('sender_id')->nullable()->comment('发送者');
            $table->json('channels')->nullable()->comment('推送渠道列表');
            $table->timestamp('read_at')->nullable()->comment('已读时间');
            $table->timestamps();
            $table->index(['notifiable_type', 'notifiable_id']);
            $table->index('read_at');
        });
    }

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