RPC 函数
PostgreSQL 自定义函数(RPC)与触发器函数清单
项目的数据库函数分为两类:RPC 函数(客户端或 Edge Function 通过 .rpc() 调用)和触发器函数(由数据库事件自动触发,不可直接调用)。
| 函数名 | 说明 |
|---|
check_comment_rate_limit | 评论频率限制检查 |
sanitize_comment_content | 评论内容净化(触发器内调用) |
| 函数名 | 说明 |
|---|
get_admin_users | 获取管理员用户列表 |
create_comic_with_tags | 创建漫画并关联标签(有重载) |
commit_app_release | 提交应用版本发布记录 |
is_admin | 检查当前用户是否为 admin(详见角色文档) |
is_admin_or_editor | 检查当前用户是否为 admin 或 editor |
| 函数名 | 说明 |
|---|
toggle_badge_display | 切换徽章显示状态 |
| 函数名 | 说明 |
|---|
cleanup_anon_sd_access_log | 清理匿名用户标清访问日志 |
reset_stale_processing | 重置卡住的处理中状态记录 |
jsonb_array_to_text | JSONB 数组转文本(工具函数) |
触发器函数由数据库事件自动执行,不通过 .rpc() 调用。
| 函数名 | 触发时机 | 说明 |
|---|
handle_new_user | 新用户注册 | 创建 profiles 记录 |
handle_new_user_role | 新用户注册 | 初始化角色 |
handle_user_update | profiles 更新 | 同步用户信息变更 |
sync_profile_to_auth_meta | profiles 更新 | 同步 profile 数据到 auth.users.raw_user_meta_data |
fn_on_signup_approved | 注册审批通过 | 处理审批通过逻辑 |
fn_on_signup_status_changed | 注册状态变更 | 处理注册状态流转 |
| 函数名 | 说明 |
|---|
handle_updated_at | 通用 updated_at 自动更新 |
update_updated_at_column | 同上(旧版命名) |
update_modified_column | 同上(旧版命名) |
| 函数名 | 触发时机 | 说明 |
|---|
auto_increment_chapter_idx | 章节插入 | 自动递增章节序号 |
sync_comic_latest_chapter | 章节变更 | 同步漫画的最新章节信息 |
notify_comic_update | 漫画更新 | 发送漫画更新通知 |
handle_new_rating | 新评分插入 | 更新漫画评分统计 |
| 函数名 | 触发时机 | 说明 |
|---|
handle_comment_like_count | 评论点赞变更 | 更新点赞计数 |
handle_comment_reply_count | 评论回复变更 | 更新回复计数 |
handle_comment_notifications | 新评论/回复 | 发送评论通知 |
handle_comment_like_notifications | 评论被点赞 | 发送点赞通知 |
| 函数名 | 触发时机 | 说明 |
|---|
handle_kanban_notifications | 看板状态变更 | 发送看板通知 |
handle_admin_audit_log | 管理操作 | 记录管理审计日志 |
handle_admin_logs | 管理操作 | 记录管理操作日志 |
update_ticket_vote_count | 工单投票变更 | 更新工单投票计数 |
| 函数名 | 触发时机 | 说明 |
|---|
call_username_moderator | profiles.display_name 更新 | 触发 AI 用户名审核(详见 AI 审核文档) |