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

// Check if settings table exists
$stmt = $pdo->query("SHOW TABLES LIKE 'settings'");
$result = $stmt->fetchAll();

if (count($result) > 0) {
    echo "Settings table exists.\n";
    
    // Check if it has the required columns
    $columns_stmt = $pdo->query("DESCRIBE settings");
    $columns = $columns_stmt->fetchAll();
    
    echo "Columns in settings table:\n";
    foreach ($columns as $column) {
        echo "- " . $column['Field'] . " (" . $column['Type'] . ")\n";
    }
    
    // Check some sample data
    try {
        $data_stmt = $pdo->query("SELECT * FROM settings LIMIT 5");
        $data = $data_stmt->fetchAll();
        echo "\nSample data from settings table:\n";
        foreach ($data as $row) {
            echo "- " . $row['setting_key'] . ": " . substr($row['setting_value'], 0, 50) . "...\n";
        }
    } catch (Exception $e) {
        echo "\nError querying settings table: " . $e->getMessage() . "\n";
    }
} else {
    echo "Settings table does not exist.\n";
    
    // Check if site_settings table exists instead
    $stmt = $pdo->query("SHOW TABLES LIKE 'site_settings'");
    $result = $stmt->fetchAll();
    
    if (count($result) > 0) {
        echo "site_settings table exists.\n";
        
        // Check columns in site_settings
        $columns_stmt = $pdo->query("DESCRIBE site_settings");
        $columns = $columns_stmt->fetchAll();
        
        echo "Columns in site_settings table:\n";
        foreach ($columns as $column) {
            echo "- " . $column['Field'] . " (" . $column['Type'] . ")\n";
        }
    } else {
        echo "Neither settings nor site_settings table exists.\n";
    }
}
?>