<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        DB::statement(
            'ALTER TABLE balance_transactions DROP CONSTRAINT IF EXISTS balance_transactions_type_check'
        );
        DB::statement(
            'ALTER TABLE balance_transactions ADD CONSTRAINT balance_transactions_type_check '.
            'CHECK (type IN ('.
            "'trial_bonus','topup','lead_charge','refund',".
            "'manual_adjustment','historical_import',".
            "'chargeback_writedown','chargeback_repayment',".
            "'migration'".
            '))'
        );
    }

    public function down(): void
    {
        DB::statement(
            'ALTER TABLE balance_transactions DROP CONSTRAINT IF EXISTS balance_transactions_type_check'
        );
        DB::statement(
            'ALTER TABLE balance_transactions ADD CONSTRAINT balance_transactions_type_check '.
            'CHECK (type IN ('.
            "'trial_bonus','topup','lead_charge','refund',".
            "'manual_adjustment','historical_import',".
            "'chargeback_writedown','chargeback_repayment'".
            '))'
        );
    }
};
