<?php
require_once __DIR__ . '/config.php';
$db = db();

$sql = "
CREATE TABLE IF NOT EXISTS project_logs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    version VARCHAR(50) NOT NULL,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
";

try {
    $db->exec($sql);
    echo "Table 'project_logs' created successfully.\n";
    
    // Insert initial version
    $stmt = $db->prepare("INSERT INTO project_logs (version, title, content) VALUES (?, ?, ?)");
    $stmt->execute(['1.0.0', 'Initial Release', 'Welcome to the project log. This is the first version of the galaxy management system.']);
    echo "Initial log entry inserted.\n";

} catch (PDOException $e) {
    echo "Error creating table: " . $e->getMessage() . "\n";
}

