<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * Master Control loyalty/voucher switches (docs/migration-plan.md Decisions Log
 * — "Master Control & Admin Settings").
 *
 * Two landlord-level kill switches, both defaulting to ON so existing tenants
 * keep the features they already have: `pos_loyalty_enabled` (points earn /
 * redeem everywhere) and `pos_vouchers_enabled` (voucher codes at the POS and
 * anywhere else a voucher is validated). When a switch is off, the UI must not
 * even render the control and the service layer must refuse to process the
 * feature (see PosSettings, VoucherService, LoyaltyService, Pos).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tenant_settings', function (Blueprint $table) {
            $table->boolean('pos_loyalty_enabled')->default(true);
            $table->boolean('pos_vouchers_enabled')->default(true);
        });
    }

    public function down(): void
    {
        Schema::table('tenant_settings', function (Blueprint $table) {
            $table->dropColumn(['pos_loyalty_enabled', 'pos_vouchers_enabled']);
        });
    }
};
