数据表结构
全部 35 张业务表的字段定义、自定义枚举与表间关系
总览
数据库共 35 张业务表(public schema),按功能分为 8 个领域。全部表均已启用 RLS。
| 领域 | 表数量 | 主要表 |
|---|---|---|
| 用户 | 3 | profiles, user_badges, badge_definitions |
| 漫画内容 | 5 | comics, chapters, categories, tags, comic_tags |
| 互动 | 6 | comic_relations, comic_likes, comics_favorites, comic_ratings, comments, comment_likes |
| 阅读 | 3 | reading_history, chapter_view_logs, anon_sd_access_log |
| 通知 | 1 | notifications |
| 支付 | 3 | products, orders, free_user_daily_premium_views |
| 工单与活动 | 5 | kanban_tickets, ticket_votes, app_events, app_event_signups, app_channel_members |
| 系统 | 9 | home_banners, announcements, app_settings, app_versions, app_release_infos, admin_logs, download_tasks, download_task_chapters |
自定义枚举
Prop
Type
用户
profiles
用户扩展信息表,id 外键关联 auth.users.id。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | — | PK,FK → auth.users.id |
username | text | YES | — | 用户名 |
display_name | text | YES | — | 显示名称 |
avatar_url | text | YES | 默认头像 URL | 头像 |
banner_url | text | YES | 'ic_banner_default' | 个人页横幅 |
vip_expiration_date | timestamptz | YES | — | VIP 到期时间 |
total_donated_amount | numeric | YES | 0 | 累计捐赠金额 |
ticket_warning_count | integer | NO | 0 | 工单警告次数 |
ticket_banned_until | timestamptz | YES | — | 工单禁言截止时间 |
moderation_meta | jsonb | YES | '{}' | AI 审核元数据 |
oidc_sub | text | YES | — | OIDC subject |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
badge_definitions
徽章定义表。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
name | text | NO | 徽章名称 |
description | text | YES | 描述 |
image_url | text | YES | 徽章图片 |
created_at | timestamptz | YES | — |
user_badges
用户持有的徽章。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
user_id | uuid | NO | FK → profiles.id |
badge_id | bigint | NO | FK → badge_definitions.id |
is_displayed | boolean | NO | 是否展示,默认 false |
expires_at | timestamptz | YES | 过期时间(NULL = 永久) |
created_at | timestamptz | YES | — |
漫画内容
comics
漫画主表。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | bigint | NO | — | PK |
title | text | NO | — | 标题 |
pinyin_name | text | YES | — | 拼音名(搜索用) |
aliases | jsonb | YES | — | 别名数组 |
slug | text | YES | — | URL slug |
summary | text | YES | — | 简介 |
note | text | YES | — | 备注 |
cover_url | text | YES | — | 封面 URL |
poster_url | text | YES | — | 海报 URL |
authors | text[] | YES | — | 作者数组 |
region | text | NO | 'jp' | 地区(jp/cn/kr 等) |
category_id | bigint | YES | — | FK → categories.id |
lock_status | text | YES | 'free' | 锁定状态 |
is_recommended | boolean | YES | false | 编辑推荐 |
is_finished | boolean | NO | false | 是否完结 |
has_upscaled | boolean | YES | false | 是否有超分辨率版本 |
release_date | date | YES | — | 发布日期 |
rating_average | numeric | YES | 0.0 | 平均评分 |
rating_count | integer | YES | 0 | 评分人数 |
view_count | integer | YES | 0 | 总浏览量 |
popularity_daily | integer | YES | 0 | 日人气 |
popularity_weekly | integer | YES | 0 | 周人气 |
popularity_monthly | integer | YES | 0 | 月人气 |
cdn_domain | text | YES | SD CDN 域名 | CDN 域名 |
latest_chapter_title | text | YES | — | 最新章节标题(冗余) |
latest_chapter_updated_at | timestamptz | YES | — | 最新章节更新时间(冗余) |
uploaded_by | uuid | YES | — | 上传者 |
processing_by | text | YES | — | 正在处理的服务标识 |
processing_started_at | timestamptz | YES | — | 处理开始时间 |
manhuagui_id | integer | YES | — | 漫画柜 ID(数据来源) |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
chapters
章节表。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | bigint | NO | — | PK |
comic_id | bigint | YES | — | FK → comics.id |
title | text | NO | — | 章节标题 |
idx | integer | YES | 0 | 排序序号 |
category | chapter_category | NO | 'normal' | 章节分类 |
chapter_folder | text | YES | — | 存储文件夹名 |
image_count | integer | YES | 0 | 图片数量 |
image_format | text | YES | 'webp' | 图片格式 |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
categories
漫画分类。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
name | text | NO | 分类名 |
slug | text | YES | URL slug |
created_at | timestamptz | YES | — |
tags
标签表。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
name | text | NO | 标签名 |
normalized_name | text | NO | 标准化名称(去重用) |
created_at | timestamptz | YES | — |
comic_tags
漫画-标签关联表(多对多)。
| 字段 | 类型 | 说明 |
|---|---|---|
comic_id | bigint | FK → comics.id |
tag_id | bigint | FK → tags.id |
互动
comic_relations
漫画关联关系(双向),用于"相关作品"。
| 字段 | 类型 | 说明 |
|---|---|---|
source_comic_id | bigint | FK → comics.id |
target_comic_id | bigint | FK → comics.id |
comic_likes
漫画点赞。
| 字段 | 类型 | 说明 |
|---|---|---|
id | bigint | PK |
user_id | uuid | FK → profiles.id |
comic_id | bigint | FK → comics.id |
created_at | timestamptz | — |
comics_favorites
漫画收藏。
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
user_id | uuid | auth.uid() | FK → profiles.id |
comic_id | bigint | — | FK → comics.id |
created_at | timestamptz | now() | — |
comic_ratings
漫画评分。
| 字段 | 类型 | 说明 |
|---|---|---|
id | bigint | PK |
user_id | uuid | FK → profiles.id |
comic_id | bigint | FK → comics.id |
score | integer | 评分值 |
created_at | timestamptz | — |
updated_at | timestamptz | — |
comments
评论表,支持嵌套回复。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | bigint | NO | — | PK |
user_id | uuid | NO | auth.uid() | FK → profiles.id |
comic_id | bigint | NO | — | FK → comics.id |
chapter_id | bigint | YES | — | FK → chapters.id(章节级评论) |
parent_id | bigint | YES | — | FK → comments.id(父评论) |
content | text | NO | — | 评论内容 |
status | comment_status | NO | 'public' | AI 审核状态 |
is_spoiler | boolean | YES | false | 剧透标记 |
like_count | integer | YES | 0 | 点赞数(冗余) |
reply_count | integer | YES | 0 | 回复数(冗余) |
report_count | integer | NO | 0 | 举报数 |
moderation_meta | jsonb | YES | '{}' | AI 审核元数据 |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
comment_likes
评论点赞。
| 字段 | 类型 | 说明 |
|---|---|---|
user_id | uuid | FK → profiles.id |
comment_id | bigint | FK → comments.id |
created_at | timestamptz | — |
阅读
reading_history
用户阅读进度。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
user_id | uuid | NO | FK → profiles.id |
comic_id | bigint | NO | FK → comics.id |
chapter_id | bigint | YES | 当前章节 |
page_index | integer | YES | 当前页码 |
chapter_title | text | YES | 章节标题(冗余) |
chapter_index | integer | YES | 章节序号(冗余) |
total_pages | integer | YES | 总页数(冗余) |
total_chapters | integer | YES | 总章节数(冗余) |
last_read_at | timestamptz | YES | 最后阅读时间 |
chapter_view_logs
登录用户章节浏览日志(用于去重计数)。
| 字段 | 类型 | 说明 |
|---|---|---|
user_id | uuid | FK → profiles.id |
chapter_id | bigint | FK → chapters.id |
viewed_at | timestamptz | 浏览时间 |
anon_sd_access_log
匿名用户标清资源访问日志。
| 字段 | 类型 | 说明 |
|---|---|---|
client_ip | text | 客户端 IP |
chapter_id | bigint | FK → chapters.id |
access_date | date | 访问日期 |
created_at | timestamptz | — |
通知
notifications
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
user_id | uuid | NO | — | 接收者 FK → profiles.id |
sender_id | uuid | YES | — | 发送者 |
type | text | NO | — | 通知类型(10 种,见通知文档) |
title | text | NO | — | 标题 |
body | text | YES | — | 正文 |
data | jsonb | YES | '{}' | 扩展数据 |
is_read | boolean | YES | false | 是否已读 |
created_at | timestamptz | YES | now() | — |
支付
products
商品表。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
name | text | NO | — | 商品名 |
description | text | YES | — | 描述 |
type | product_type | YES | 'subscription' | 商品类型 |
price | numeric | NO | — | 价格 |
duration_days | integer | NO | — | VIP 天数 |
image_url | text | YES | — | 商品图片 |
is_active | boolean | YES | true | 是否上架 |
sort_order | integer | YES | 0 | 排序 |
stock_limit | integer | YES | — | 库存限制 |
sales_count | integer | YES | 0 | 销量 |
promotion_start_at | timestamptz | YES | — | 促销开始 |
promotion_end_at | timestamptz | YES | — | 促销结束 |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
orders
订单表(详见支付文档)。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
user_id | uuid | NO | — | FK → profiles.id |
product_id | uuid | YES | — | FK → products.id |
product_snapshot | jsonb | NO | — | 下单时的商品快照 |
trade_no | text | NO | — | 内部订单号 |
hypay_trade_no | text | YES | — | Hypay 订单号 |
pay_url | text | YES | — | 支付链接 |
amount | numeric | NO | — | 金额 |
quantity | integer | NO | 1 | 数量 |
status | order_status | YES | 'pending' | 订单状态 |
paid_at | timestamptz | YES | — | 支付时间 |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
free_user_daily_premium_views
免费用户每日高清配额消耗记录(详见配额文档)。
| 字段 | 类型 | 说明 |
|---|---|---|
id | bigint | PK |
user_id | uuid | FK → profiles.id |
chapter_id | bigint | FK → chapters.id |
view_date | date | 日期(默认 CURRENT_DATE) |
viewed_at | timestamptz | 浏览时间 |
唯一约束:(user_id, chapter_id, view_date)
工单与活动
kanban_tickets
看板工单。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
title | text | NO | — | 标题 |
description | text | YES | — | 描述 |
domain | ticket_domain | NO | — | 领域(DEV / OPS) |
category | text | NO | — | 分类 |
status | ticket_status | YES | 'RECORDED' | 状态 |
priority | integer | YES | 0 | 优先级 |
action_type | text | YES | — | 操作类型 |
reporter_id | uuid | YES | — | 报告者 |
assignee_id | uuid | YES | — | 指派人 |
is_public | boolean | YES | false | 是否公开 |
vote_count | integer | YES | 0 | 投票数(冗余) |
meta_info | jsonb | YES | '{}' | 扩展信息 |
admin_response | text | YES | — | 管理员回复 |
is_violation | boolean | NO | false | 是否违规 |
violation_reason | text | YES | — | 违规原因 |
violation_operator_id | uuid | YES | — | 标记违规的操作者 |
violation_marked_at | timestamptz | YES | — | 标记违规时间 |
created_at | timestamptz | YES | now() | — |
updated_at | timestamptz | YES | now() | — |
ticket_votes
工单投票。
| 字段 | 类型 | 说明 |
|---|---|---|
ticket_id | uuid | FK → kanban_tickets.id |
user_id | uuid | FK → profiles.id |
created_at | timestamptz | — |
app_events
应用活动。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | bigint | NO | — | PK |
event_type | text | NO | 'general' | 活动类型 |
title | text | NO | — | 标题 |
description | text | YES | — | 描述 |
cover_url | text | YES | — | 封面 |
max_members | integer | YES | — | 人数上限 |
starts_at | timestamptz | YES | — | 开始时间 |
ends_at | timestamptz | YES | — | 结束时间 |
is_active | boolean | NO | true | 是否激活 |
form_schema | jsonb | NO | '[]' | 报名表单 schema |
settings | jsonb | NO | '{}' | 活动设置 |
created_at | timestamptz | NO | now() | — |
app_event_signups
活动报名。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | bigint | NO | — | PK |
event_id | bigint | NO | — | FK → app_events.id |
user_id | uuid | NO | — | FK → profiles.id |
form_data | jsonb | NO | '{}' | 表单数据 |
status | text | NO | 'pending' | 审核状态 |
reviewed_by | uuid | YES | — | 审核人 |
reviewed_at | timestamptz | YES | — | 审核时间 |
admin_note | text | YES | — | 管理员备注 |
created_at | timestamptz | NO | now() | — |
app_channel_members
应用渠道成员(内测 / 特殊渠道)。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
device_id | text | NO | 设备 ID |
channel | text | NO | 渠道标识 |
note | text | YES | 备注 |
is_active | boolean | YES | 是否激活 |
created_at | timestamptz | YES | — |
系统
home_banners
首页轮播图。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
title | text | NO | — | 标题 |
subtitle | text | YES | — | 副标题 |
image_url | text | NO | — | 图片 URL |
target_type | text | NO | 'comic' | 跳转类型 |
target_value | text | YES | — | 跳转目标值 |
sort_order | integer | NO | 0 | 排序 |
is_active | boolean | NO | true | 是否激活 |
start_at | timestamptz | YES | — | 生效时间 |
end_at | timestamptz | YES | — | 失效时间 |
created_at | timestamptz | NO | now() | — |
updated_at | timestamptz | NO | now() | — |
announcements
系统公告。
| 字段 | 类型 | 可空 | 默认值 | 说明 |
|---|---|---|---|---|
id | uuid | NO | gen_random_uuid() | PK |
title | text | NO | — | 标题 |
content | text | YES | — | 摘要内容 |
detail_content | text | YES | — | 详情内容 |
announcement_type | text | NO | 'info' | 类型 |
action_text | text | YES | — | 按钮文本 |
action_url | text | YES | — | 按钮链接 |
priority | integer | NO | 0 | 优先级 |
is_active | boolean | NO | true | 是否激活 |
is_dismissible | boolean | NO | true | 是否可关闭 |
is_popup | boolean | NO | false | 是否弹窗 |
start_at | timestamptz | YES | — | 生效时间 |
end_at | timestamptz | YES | — | 失效时间 |
created_at | timestamptz | NO | now() | — |
updated_at | timestamptz | NO | now() | — |
app_settings
全局配置键值表。
| 字段 | 类型 | 说明 |
|---|---|---|
key | text | PK,配置键 |
value | jsonb | 配置值 |
description | text | 说明 |
updated_at | timestamptz | 更新时间 |
app_versions
应用版本记录(由 check-update 使用)。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
release_info_id | bigint | YES | FK → app_release_infos.id |
version_code | integer | NO | 版本号 |
version_name | text | NO | 版本名 |
min_supported_code | integer | YES | 最低支持版本 |
min_sdk | integer | YES | 最低 SDK 版本 |
staged_rollout_percent | integer | YES | 灰度比例(默认 100) |
channel | text | NO | 渠道 |
apk_data | jsonb | YES | APK 信息 |
splits_data | jsonb | YES | Split APK 信息 |
created_at | timestamptz | YES | — |
app_release_infos
版本发布说明。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | bigint | NO | PK |
version_name | text | NO | 版本名 |
release_notes | text | YES | 更新日志 |
announcement | text | YES | 版本公告 |
created_at | timestamptz | YES | — |
updated_at | timestamptz | YES | — |
admin_logs
管理操作审计日志。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | uuid | NO | PK |
admin_id | uuid | NO | 操作者 |
target_user_id | uuid | YES | 目标用户 |
action_type | text | NO | 操作类型 |
details | jsonb | YES | 详情 |
ip_address | text | YES | IP 地址 |
created_at | timestamptz | NO | — |
download_tasks
漫画下载任务(自动化服务使用)。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | integer | NO | PK(自增) |
task_id | integer | NO | 任务标识 |
manhuagui_id | integer | NO | 源站 ID |
comic_title | text | NO | 漫画标题 |
status | text | NO | 状态(默认 'running') |
total_chapters | integer | YES | 总章节数 |
completed_chapters | integer | YES | 完成数 |
failed_chapters | integer | YES | 失败数 |
current_stage | text | YES | 当前阶段 |
error | text | YES | 错误信息 |
started_at | timestamptz | YES | 开始时间 |
completed_at | timestamptz | YES | 完成时间 |
created_at | timestamptz | YES | — |
updated_at | timestamptz | YES | — |
download_task_chapters
下载任务的章节明细。
| 字段 | 类型 | 可空 | 说明 |
|---|---|---|---|
id | integer | NO | PK(自增) |
task_id | integer | NO | FK → download_tasks.id |
chapter_id | integer | NO | 章节 ID |
chapter_title | text | YES | 章节标题 |
chapter_folder | text | YES | 文件夹名 |
status | text | NO | 状态(默认 'pending') |
current_stage | text | YES | 当前阶段 |
error | text | YES | 错误信息 |
retry_count | integer | YES | 重试次数 |
max_retries | integer | YES | 最大重试次数(默认 3) |
retry_stage | text | YES | 重试阶段 |
created_at | timestamptz | YES | — |
updated_at | timestamptz | YES | — |