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

CREATE TABLE `kku_urs_promotion_user_mappings` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `urs_user_id` bigint(20) unsigned NOT NULL COMMENT 'URS用户ID',
  `user_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'URS用户凭证(userKey)',
  `user_id` bigint(20) unsigned NOT NULL COMMENT '农场用户ID',
  `mapping_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '映射建立时间（用户进入农场时间）',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态:1有效,0无效',
  `is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否活跃:1活跃,0不活跃',
  `last_activity_check` timestamp NULL DEFAULT NULL COMMENT '最后活跃检查时间',
  `active_days_count` int(11) NOT NULL DEFAULT '0' COMMENT '活跃天数统计',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_urs_user_id` (`urs_user_id`) USING BTREE,
  UNIQUE KEY `uk_user_id` (`user_id`) USING BTREE,
  KEY `idx_status` (`status`) USING BTREE,
  KEY `idx_mapping_time` (`mapping_time`) USING BTREE,
  KEY `idx_user_key` (`user_key`) USING BTREE,
  KEY `idx_is_active` (`is_active`) USING BTREE,
  KEY `idx_last_activity_check` (`last_activity_check`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='URS用户与农场用户关系映射表';
