<?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::table('tenants', function (Blueprint $table) {
            // 용량 관리
            $table->bigInteger('storage_limit')->default(10737418240)->comment('저장소 한도 (10GB)');
            $table->bigInteger('storage_used')->default(0)->comment('사용 중인 용량 (bytes)');
            $table->timestamp('storage_warning_sent_at')->nullable()->comment('90% 경고 발송 시간');
            $table->timestamp('storage_grace_period_until')->nullable()->comment('유예 기간 종료 시간 (7일)');

            // 인덱스
            $table->index(['storage_used'], 'idx_storage_used');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('tenants', function (Blueprint $table) {
            $table->dropIndex('idx_storage_used');
            $table->dropColumn([
                'storage_limit',
                'storage_used',
                'storage_warning_sent_at',
                'storage_grace_period_until',
            ]);
        });
    }
};
