<?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_exports', function (Blueprint $table) {
            $table->id();
            $table->string('type', 50)->comment('导出类型');
            $table->string('filename', 255)->comment('文件名');
            $table->string('status', 20)->default('pending')->comment('pending,processing,completed,failed');
            $table->unsignedBigInteger('rows')->default(0)->comment('总行数');
            $table->string('path', 500)->nullable()->comment('文件路径');
            $table->text('error')->nullable()->comment('错误信息');
            $table->json('filters')->nullable()->comment('筛选条件');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->timestamps();
            $table->index('user_id');
            $table->index('status');
        });
    }

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