Files
zt-closet-backend/pkg/migration/000005_create_user_quotas.up.sql
T
2026-09-11 01:41:52 +08:00

33 lines
2.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
CREATE TABLE `user_quotas` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`created_at` BIGINT NOT NULL DEFAULT 0 COMMENT '创建时间',
`updated_at` BIGINT NOT NULL DEFAULT 0 COMMENT '更新时间',
`deleted_at` BIGINT NOT NULL DEFAULT 0 COMMENT '删除时间(0 表示未删除)',
`created_by` BIGINT NOT NULL DEFAULT 0 COMMENT '创建人',
`updated_by` BIGINT NOT NULL DEFAULT 0 COMMENT '更新人',
`deleted_by` BIGINT NOT NULL DEFAULT 0 COMMENT '删除人',
`user_id` BIGINT NOT NULL DEFAULT 0 COMMENT '用户ID',
`quota_type` TINYINT NOT NULL DEFAULT 0 COMMENT '额度类型 1=cos上传 2=AI推荐 3=社区分享 4=衣柜分享',
`total` BIGINT NOT NULL DEFAULT 0 COMMENT '总配额',
`used` BIGINT NOT NULL DEFAULT 0 COMMENT '已用量',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_quota` (`user_id`, `quota_type`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '用户额度表';
CREATE TABLE `user_daily_usages` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`created_at` BIGINT NOT NULL DEFAULT 0 COMMENT '创建时间',
`updated_at` BIGINT NOT NULL DEFAULT 0 COMMENT '更新时间',
`deleted_at` BIGINT NOT NULL DEFAULT 0 COMMENT '删除时间(0 表示未删除)',
`created_by` BIGINT NOT NULL DEFAULT 0 COMMENT '创建人',
`updated_by` BIGINT NOT NULL DEFAULT 0 COMMENT '更新人',
`deleted_by` BIGINT NOT NULL DEFAULT 0 COMMENT '删除人',
`user_id` BIGINT NOT NULL DEFAULT 0 COMMENT '用户ID',
`stat_date` BIGINT NOT NULL DEFAULT 0 COMMENT '统计日期(YYYYMMDD)',
`ai_recommend_count` BIGINT NOT NULL DEFAULT 0 COMMENT '当日AI推荐次数',
`outfit_share_count` BIGINT NOT NULL DEFAULT 0 COMMENT '当日社区分享次数',
`closet_share_count` BIGINT NOT NULL DEFAULT 0 COMMENT '当日衣柜分享次数',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_daily_usage_user_date` (`user_id`, `stat_date`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '用户每日用量统计表';