<?php

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

class AddFinanceSsoSecret extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('finance_settings')) {
            return;
        }

        Schema::table('finance_settings', function (Blueprint $table) {
            if (!Schema::hasColumn('finance_settings', 'sso_secret')) {
                $table->string('sso_secret')->nullable()->after('webhook_secret');
            }
        });
    }

    public function down()
    {
        if (!Schema::hasTable('finance_settings') || !Schema::hasColumn('finance_settings', 'sso_secret')) {
            return;
        }

        Schema::table('finance_settings', function (Blueprint $table) {
            $table->dropColumn('sso_secret');
        });
    }
}
