-- Migration: Create user_ntfy_settings table
CREATE TABLE IF NOT EXISTS user_ntfy_settings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER NOT NULL,
    enabled BOOLEAN NOT NULL DEFAULT 0,
    topic TEXT NOT NULL,
    server_url TEXT NOT NULL,
    priority INTEGER NOT NULL DEFAULT 5,
    title_template TEXT,
    message_template TEXT,
    FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_ntfy_settings_user_id ON user_ntfy_settings(user_id);

-- Migration: Create user_smtp_settings table
CREATE TABLE IF NOT EXISTS user_smtp_settings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER NOT NULL,
    enabled BOOLEAN NOT NULL DEFAULT 0,
    email TEXT NOT NULL,
    smtp_server TEXT NOT NULL,
    smtp_port INTEGER NOT NULL,
    username TEXT,
    password TEXT,
    use_tls BOOLEAN NOT NULL DEFAULT 1,
    from_email TEXT,
    from_name TEXT DEFAULT 'Silmätaivas Alerts',
    subject_template TEXT,
    body_template TEXT,
    FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_smtp_settings_user_id ON user_smtp_settings(user_id); 