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

try {
    $tables = fetchAll("SHOW TABLES");
    foreach ($tables as $tRow) {
        $tableName = array_values($tRow)[0];
        echo "Table: $tableName\n";
        $columns = fetchAll("DESCRIBE `$tableName`");
        foreach ($columns as $col) {
            echo "  - {$col['Field']} ({$col['Type']}) " . ($col['Null'] === 'NO' ? 'NOT NULL' : 'NULL') . ($col['Key'] ? " KEY: {$col['Key']}" : "") . ($col['Default'] ? " DEFAULT: {$col['Default']}" : "") . "\n";
        }
        echo "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
