<?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::table('franchises', function (Blueprint $table): void {
            $table->string('area')->nullable()->after('address');
            $table->decimal('commission_percent', 5, 2)->default(0)->after('wallet_balance');
        });

        Schema::table('user_binary_carry', function (Blueprint $table): void {
            $table->timestamp('last_joining_processed_at')->nullable()->after('last_processed_at');
            $table->timestamp('last_repurchase_processed_at')->nullable()->after('last_joining_processed_at');
        });
    }

    public function down(): void
    {
        Schema::table('user_binary_carry', function (Blueprint $table): void {
            $table->dropColumn(['last_joining_processed_at', 'last_repurchase_processed_at']);
        });

        Schema::table('franchises', function (Blueprint $table): void {
            $table->dropColumn(['area', 'commission_percent']);
        });
    }
};
