<?php
header('Content-Type: text/plain');

$host = '127.0.0.1'; 
$db   = 'db_iqpj6ze2cf';
$user = 'db_iqpj6ze2cf';
$pass = 'O*9Mp;%5Ppyv8oD';

try {
    $pdo = new PDO("pgsql:host=$host;dbname=$db", $user, $pass);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    echo "Connected to Database...\n";

    $sql = "ALTER TABLE shopify_orders 
            ADD COLUMN IF NOT EXISTS agent VARCHAR(255),
            ADD COLUMN IF NOT EXISTS status VARCHAR(50) DEFAULT 'Pending',
            ADD COLUMN IF NOT EXISTS agent_remark TEXT,
            ADD COLUMN IF NOT EXISTS awb VARCHAR(255),
            ADD COLUMN IF NOT EXISTS courier VARCHAR(255),
            ADD COLUMN IF NOT EXISTS courier_name VARCHAR(255),
            ADD COLUMN IF NOT EXISTS dispatch_status VARCHAR(50),
            ADD COLUMN IF NOT EXISTS dispatch_date TIMESTAMP,
            ADD COLUMN IF NOT EXISTS last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP";

    $pdo->exec($sql);
    echo "SUCCESS: All Dashboard columns have been added to shopify_orders!\n";

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