<?php

declare(strict_types=1);

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('point_rules', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('tenant_id')->constrained('tenants')->cascadeOnDelete();
            $table->enum('action', [
                'post_create', 'comment_create',
                'post_liked', 'comment_liked',
                'login_daily', 'first_purchase',
                'referral', 'birthday',
            ]);
            $table->integer('points')->default(0);
            $table->unsignedInteger('cap_per_day')->nullable();
            $table->boolean('is_active')->default(true);
            $table->timestamps();

            $table->unique(['tenant_id', 'action']);
        });
    }

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