<?php
require 'includes/db.php';
try {
    $pdo->exec("ALTER TABLE products DROP COLUMN IF EXISTS category");
    $pdo->exec("ALTER TABLE products ADD COLUMN IF NOT EXISTS units INT DEFAULT 0 AFTER base_price");
    // Ensure SKU is unique
    // First, let's check if index exists
    $pdo->exec("ALTER TABLE products MODIFY COLUMN sku VARCHAR(50) NOT NULL UNIQUE");
    echo "Products table updated successfully.";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
