<?php
$host = '127.0.0.1';
$db = 'nexcore_pharma';
$user = 'nexcore_pharma';
$pass = 'nexova@2026';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8mb4", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // Check if max_whatsapp_recipients exists
    $stmt = $pdo->query("SHOW COLUMNS FROM tenants LIKE 'max_whatsapp_recipients'");
    if ($stmt->rowCount() == 0) {
        $pdo->exec("ALTER TABLE tenants ADD COLUMN max_whatsapp_recipients INT DEFAULT 1");
        echo "Added max_whatsapp_recipients column.\n";
    } else {
        echo "max_whatsapp_recipients already exists.\n";
    }

    echo "Migration completed successfully.\n";
} catch(PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}
