<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

file_put_contents('start.txt', 'Started at ' . date('H:i:s'));

include 'includes/db.php';

$sql = "CREATE TABLE IF NOT EXISTS blogs (
    id INT(11) NOT NULL AUTO_INCREMENT,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    image_url VARCHAR(255) DEFAULT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
)";

if ($conn->query($sql) === TRUE) {
    file_put_contents('creation_status.txt', "Table 'blogs' created successfully at " . date('Y-m-d H:i:s'));
    echo "Success";
} else {
    file_put_contents('creation_status.txt', "Error: " . $conn->error);
    echo "Error";
}

$conn->close();
?>
