manghe/create_sign_tables.sql
2025-04-01 15:28:42 +00:00

45 lines
2.2 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 IF NOT EXISTS `reward` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`reward_type` tinyint(1) NOT NULL COMMENT '奖励类型(1:优惠券,2:钻石,3:货币1,4:货币2)',
`reward_id` int(11) DEFAULT NULL COMMENT '奖励ID(当reward_type=1时为优惠券ID)',
`reward_value` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '奖励值',
`title` varchar(100) DEFAULT NULL COMMENT '奖励标题',
`description` varchar(255) DEFAULT NULL COMMENT '奖励描述',
`icon` varchar(255) DEFAULT NULL COMMENT '奖励图标',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态(0禁用,1启用)',
`create_time` int(11) DEFAULT NULL,
`update_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='奖励表';
-- 创建签到配置表
CREATE TABLE IF NOT EXISTS `sign_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL COMMENT '配置类型(1:累计签到配置,2:每日签到配置)',
`days` int(11) DEFAULT NULL COMMENT '累计天数(type=1时有效)',
`day` tinyint(1) DEFAULT NULL COMMENT '指定星期几(type=2时有效1-7代表周一到周日)',
`title` varchar(100) DEFAULT NULL COMMENT '配置标题',
`icon` varchar(255) DEFAULT NULL COMMENT '图标',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态(0禁用,1启用)',
`sort` int(11) DEFAULT '0' COMMENT '排序',
`create_time` int(11) DEFAULT NULL,
`update_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='签到配置表';
-- 创建签到配置奖励关联表
CREATE TABLE IF NOT EXISTS `sign_config_reward` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sign_config_id` int(11) NOT NULL COMMENT '签到配置ID',
`reward_id` int(11) NOT NULL COMMENT '奖励ID',
`create_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_sign_config_id` (`sign_config_id`),
KEY `idx_reward_id` (`reward_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='签到配置奖励关联表';
-- 修改用户签到表添加month和year字段
ALTER TABLE `user_sign`
ADD COLUMN `month` int(11) DEFAULT NULL COMMENT '签到月份' AFTER `days`,
ADD COLUMN `year` int(11) DEFAULT NULL COMMENT '签到年份' AFTER `month`;