<?php
$mysqli = new mysqli("localhost", "root", "", "mcc_lms");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

$sql_content = "CREATE TABLE IF NOT EXISTS course_content (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    topic_id INT UNSIGNED NOT NULL,
    title VARCHAR(255) NOT NULL,
    content_type ENUM('text', 'pdf', 'video', 'audio', 'presentation', 'youtube') NOT NULL,
    content_text LONGTEXT,
    file_path VARCHAR(500),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (topic_id) REFERENCES topics(id) ON DELETE CASCADE
)";

if ($mysqli->query($sql_content) === TRUE) {
    echo "Table course_content created successfully.\n";
} else {
    echo "Error creating course_content: " . $mysqli->error . "\n";
}

$mysqli->close();
