<?php
require_once __DIR__ . '/api/config/database.php';

try {
    $db = Database::connect();
    
    // Check if column exists first
    $stmt = $db->query("SHOW COLUMNS FROM sale_master LIKE 'due_date'");
    if ($stmt->rowCount() == 0) {
        $db->exec('ALTER TABLE sale_master ADD COLUMN due_date DATE DEFAULT NULL AFTER voucher_date');
        echo "Column added successfully.";
    } else {
        echo "Column already exists.";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
