<?php
require_once 'includes/config.php';
require_once 'includes/db.php';

// Update the product_comments table to add updated_at column
try {
    // Check if the updated_at column already exists
    $stmt = $pdo->prepare("SHOW COLUMNS FROM `product_comments` LIKE 'updated_at'");
    $stmt->execute();
    $column_exists = $stmt->fetch();
    
    if (!$column_exists) {
        // Add the updated_at column
        $sql = "ALTER TABLE `product_comments` ADD `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
        $pdo->exec($sql);
        echo "Column 'updated_at' added to product_comments table successfully!";
    } else {
        echo "Column 'updated_at' already exists in product_comments table.";
    }
} catch (Exception $e) {
    echo "Error updating table: " . $e->getMessage();
}
?>