<?php
require_once 'config/db.php';

try {
    $sql = "CREATE TABLE IF NOT EXISTS notifications (
        id INT AUTO_INCREMENT PRIMARY KEY,
        user_id INT NOT NULL,
        type VARCHAR(50) NOT NULL, -- 'follow', 'gift', 'order', 'system'
        title VARCHAR(100),
        message TEXT,
        is_read BOOLEAN DEFAULT FALSE,
        link VARCHAR(255) NULL, -- Optional action link
        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
    )";
    $pdo->exec($sql);
    echo "✅ Table 'notifications' created successfully.<br>";

    echo "<hr>🎉 Notifications DB Setup Complete!";

} catch (PDOException $e) {
    die("❌ DB Error: " . $e->getMessage());
}
?>
