Files
zt-closet-backend/pkg/migration/000019_create_outfit_shares.up.sql
T
2026-09-13 23:32:22 +08:00

32 lines
2.0 KiB
SQL

CREATE TABLE `outfit_shares` (
`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 '删除人',
`share_uuid` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '分享UUID',
`user_id` BIGINT NOT NULL DEFAULT 0 COMMENT '所属用户ID',
`outfit_id` BIGINT NOT NULL DEFAULT 0 COMMENT '穿搭ID',
`status` TINYINT NOT NULL DEFAULT 0 COMMENT '分享状态 1=正常 2=用户取消',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_outfit_shares_uuid` (`share_uuid`),
KEY `idx_outfit_shares_user_status` (`user_id`, `status`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '穿搭分享表';
CREATE TABLE `outfit_share_receivers` (
`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 '删除人',
`share_uuid` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '分享UUID',
`receiver_user_id` BIGINT NOT NULL DEFAULT 0 COMMENT '接收人用户ID',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_outfit_share_receiver` (`share_uuid`, `receiver_user_id`),
KEY `idx_outfit_share_receivers_user` (`receiver_user_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '穿搭分享接收人关联表';