<?php
/**
 * Enable allow_direct_deposit for all existing cash and bank accounts
 */

try {
    $dsn = "mysql:host=localhost;dbname=naveed_trader_db;charset=utf8mb4";
    $db = new PDO($dsn, "root", "", [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"
    ]);

    echo "Connected to database.\n";

    echo "Enabling allow_direct_deposit for all existing bank_cash accounts...\n";
    $count = $db->exec("UPDATE accounts SET allow_direct_deposit = 1 WHERE type = 'bank_cash'");
    echo "Updated {$count} accounts successfully.\n";

    echo "\nSUCCESS!\n";

} catch (PDOException $e) {
    echo "ERROR: " . $e->getMessage() . "\n";
}
