<?php
/**
 * Migration Runner - Add shipping_amount to sales table
 * Access this file in your browser: http://your-domain/run_shipping_migration.php
 */

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

try {
    $sql = file_get_contents(__DIR__ . '/database/migrations/add_shipping_to_sales.sql');
    
    if (!$sql) {
        die('Error: Could not read migration file.');
    }
    
    db()->exec($sql);
    
    echo '<h1>Migration Successful!</h1>';
    echo '<p>The shipping_amount column has been added to the sales table.</p>';
    echo '<p><a href="/sales/pos">Go to POS Terminal</a></p>';
    
} catch (PDOException $e) {
    echo '<h1>Migration Error</h1>';
    echo '<p>Error: ' . $e->getMessage() . '</p>';
    echo '<p>The column may already exist. This is not a problem if you see this error.</p>';
}
