<?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
    {
        if (Schema::hasTable('system_email_quota')) {
            return;
        }

        Schema::create('system_email_quota', function (Blueprint $table): void {
            $table->id();
            $table->string('period', 7)->unique();
            $table->unsignedInteger('sent_count')->default(0);
            $table->unsignedInteger('limit_count');
            $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
        });
    }

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