-- ******************************************************************
-- 表 kku_point_logs 的创建SQL
-- 对应的Model: App\Module\Point\Models\PointLogModel
-- 警告: 此文件由系统自动生成，禁止修改！
-- ******************************************************************

CREATE TABLE `kku_point_logs` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增',
  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  `point_id` int(11) NOT NULL DEFAULT '0' COMMENT '积分类型ID',
  `amount` bigint(20) NOT NULL DEFAULT '0' COMMENT '操作积分数量,正值为收入,负值为支出',
  `operate_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '上游操作ID',
  `operate_type` int(11) NOT NULL DEFAULT '0' COMMENT '上游操作类型',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '备注',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `create_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '创建IP',
  `later_balance` bigint(20) NOT NULL DEFAULT '0' COMMENT '操作后余额',
  `before_balance` bigint(20) NOT NULL DEFAULT '0' COMMENT '操作前余额',
  `date_key` int(11) NOT NULL DEFAULT '0' COMMENT '日期key（用于分表）',
  `hash` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '防篡改哈希值',
  `prev_hash` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '上一条记录的哈希值',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_user_id` (`user_id`) USING BTREE,
  KEY `idx_point_id` (`point_id`) USING BTREE,
  KEY `idx_operate_type` (`operate_type`) USING BTREE,
  KEY `idx_create_time` (`create_time`) USING BTREE,
  KEY `idx_date_key` (`date_key`) USING BTREE,
  KEY `idx_user_point_time` (`user_id`,`point_id`,`create_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='积分日志表';
