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

try {
    // Add 'due' to payment_status ENUM in sales table
    $sql1 = "ALTER TABLE sales MODIFY COLUMN payment_status ENUM('paid','partial','due','credit') DEFAULT 'paid'";
    db()->exec($sql1);
    echo "✓ Updated sales table payment_status ENUM to include 'due'\n";
    
    // Add 'due' to payment_status ENUM in purchases table
    $sql2 = "ALTER TABLE purchases MODIFY COLUMN payment_status ENUM('paid','partial','due','credit') DEFAULT 'paid'";
    db()->exec($sql2);
    echo "✓ Updated purchases table payment_status ENUM to include 'due'\n";
    
    echo "\nMigration completed successfully!\n";
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
