<?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::create('barobill_pricing_policies', function (Blueprint $table) {
            $table->id();
            $table->string('service_type', 50)->comment('서비스 유형: card, tax_invoice, bank_account');
            $table->string('name', 100)->comment('정책명');
            $table->string('description')->nullable()->comment('설명');

            // 기본 무료 제공량
            $table->integer('free_quota')->default(0)->comment('무료 기본 제공량');
            $table->string('free_quota_unit', 20)->default('개')->comment('무료 제공 단위 (장, 건, 개 등)');

            // 추가 과금 설정
            $table->integer('additional_unit')->default(1)->comment('추가 과금 단위 (1, 50 등)');
            $table->string('additional_unit_label', 20)->default('개')->comment('추가 단위 라벨');
            $table->integer('additional_price')->default(0)->comment('추가 과금 금액 (원)');

            $table->boolean('is_active')->default(true)->comment('활성화 여부');
            $table->integer('sort_order')->default(0)->comment('정렬 순서');

            $table->timestamps();

            $table->unique('service_type');
            $table->index('is_active');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('barobill_pricing_policies');
    }
};
