CREATE TABLE IF NOT EXISTS `share_links` (
  `id` BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '分享ID',
  `project_id` BIGINT NOT NULL COMMENT '项目ID',
  `share_type` VARCHAR(20) NOT NULL COMMENT '分享类型: project/file',
  `share_code` VARCHAR(64) NOT NULL COMMENT '公开分享码',
  `file_path` VARCHAR(500) DEFAULT NULL COMMENT '文件路径，仅文件分享使用',
  `access_pass` VARCHAR(100) DEFAULT NULL COMMENT '访问密码',
  `created_by` BIGINT DEFAULT NULL COMMENT '创建人ID',
  `status` TINYINT DEFAULT 1 COMMENT '状态：0-禁用 1-启用',
  `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  UNIQUE KEY `uk_share_code` (`share_code`),
  INDEX `idx_share_project` (`project_id`, `share_type`, `status`),
  INDEX `idx_share_file` (`project_id`, `file_path`(255), `status`),
  INDEX `idx_share_created_by` (`created_by`),
  FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON DELETE CASCADE,
  FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分享链接表';
