<?php
include 'includes/db.php';

try {
    $sql = "
    CREATE TABLE IF NOT EXISTS `gastos` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `categoria` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
      `descripcion` text COLLATE utf8mb4_general_ci,
      `monto` decimal(10,2) NOT NULL DEFAULT '0.00',
      `fecha` datetime DEFAULT CURRENT_TIMESTAMP,
      `comprobante` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
    ";
    $pdo->exec($sql);
    echo "Table 'gastos' created or already exists.";
} catch (PDOException $e) {
    echo "Error creating table: " . $e->getMessage();
}
?>