<?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('kpi_targets', function (Blueprint $table) {
            $table->id();

            $table->string('metric_key', 100);
            $table->string('granularity', 10); // day | week | month
            $table->decimal('value', 12, 2)->nullable();

            $table->timestamps();

            $table->unique(['metric_key', 'granularity']);
        });
    }

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