/*
Navicat MySQL Data Transfer

Source Server         : localhost
Source Server Version : 80022
Source Host           : localhost:3306
Source Database       : ry_refactor0120

Target Server Type    : MYSQL
Target Server Version : 80022
File Encoding         : 65001

Date: 2026-01-21 10:00:00
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_stocks_in_trend (趋势中的股票表 - 按月分区)
-- ----------------------------
DROP TABLE IF EXISTS `t_stocks_in_trend`;
CREATE TABLE `t_stocks_in_trend` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `stock_code` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '股票代码',
  `trade_date` date NOT NULL COMMENT '交易日期',
  `rank` int NULL DEFAULT -1 COMMENT '排名',
  `momentum_type` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动量数据类型（10日、20日）',
  `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`, `stock_code`, `trade_date`, `momentum_type`),
  INDEX `idx_pk_id` (`id`),
  INDEX `idx_stock_code` (`stock_code`),
  INDEX `idx_trade_date` (`trade_date`),
  INDEX `idx_momentum_type` (`momentum_type`),
  INDEX `idx_rank` (`rank`),
  INDEX `idx_create_time` (`create_time`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '趋势中的股票表' ROW_FORMAT = Dynamic
PARTITION BY RANGE (YEAR(trade_date)*100 + MONTH(trade_date)) (
    PARTITION p202111 VALUES LESS THAN (202112),
    PARTITION p202112 VALUES LESS THAN (202201),
    PARTITION p202201 VALUES LESS THAN (202202),
    PARTITION p202202 VALUES LESS THAN (202203),
    PARTITION p202203 VALUES LESS THAN (202204),
    PARTITION p202204 VALUES LESS THAN (202205),
    PARTITION p202205 VALUES LESS THAN (202206),
    PARTITION p202206 VALUES LESS THAN (202207),
    PARTITION p202207 VALUES LESS THAN (202208),
    PARTITION p202208 VALUES LESS THAN (202209),
    PARTITION p202209 VALUES LESS THAN (202210),
    PARTITION p202210 VALUES LESS THAN (202211),
    PARTITION p202211 VALUES LESS THAN (202212),
    PARTITION p202212 VALUES LESS THAN (202301),
    PARTITION p202301 VALUES LESS THAN (202302),
    PARTITION p202302 VALUES LESS THAN (202303),
    PARTITION p202303 VALUES LESS THAN (202304),
    PARTITION p202304 VALUES LESS THAN (202305),
    PARTITION p202305 VALUES LESS THAN (202306),
    PARTITION p202306 VALUES LESS THAN (202307),
    PARTITION p202307 VALUES LESS THAN (202308),
    PARTITION p202308 VALUES LESS THAN (202309),
    PARTITION p202309 VALUES LESS THAN (202310),
    PARTITION p202310 VALUES LESS THAN (202311),
    PARTITION p202311 VALUES LESS THAN (202312),
    PARTITION p202312 VALUES LESS THAN (202401),
    PARTITION p202401 VALUES LESS THAN (202402),
    PARTITION p202402 VALUES LESS THAN (202403),
    PARTITION p202403 VALUES LESS THAN (202404),
    PARTITION p202404 VALUES LESS THAN (202405),
    PARTITION p202405 VALUES LESS THAN (202406),
    PARTITION p202406 VALUES LESS THAN (202407),
    PARTITION p202407 VALUES LESS THAN (202408),
    PARTITION p202408 VALUES LESS THAN (202409),
    PARTITION p202409 VALUES LESS THAN (202410),
    PARTITION p202410 VALUES LESS THAN (202411),
    PARTITION p202411 VALUES LESS THAN (202412),
    PARTITION p202412 VALUES LESS THAN (202501),
    PARTITION p202501 VALUES LESS THAN (202502),
    PARTITION p202502 VALUES LESS THAN (202503),
    PARTITION p202503 VALUES LESS THAN (202504),
    PARTITION p202504 VALUES LESS THAN (202505),
    PARTITION p202505 VALUES LESS THAN (202506),
    PARTITION p202506 VALUES LESS THAN (202507),
    PARTITION p202507 VALUES LESS THAN (202508),
    PARTITION p202508 VALUES LESS THAN (202509),
    PARTITION p202509 VALUES LESS THAN (202510),
    PARTITION p202510 VALUES LESS THAN (202511),
    PARTITION p202511 VALUES LESS THAN (202512),
    PARTITION p202512 VALUES LESS THAN (202601),
    PARTITION p202601 VALUES LESS THAN (202602),
    PARTITION p202602 VALUES LESS THAN (202603),
    PARTITION p202603 VALUES LESS THAN (202604),
    PARTITION p202604 VALUES LESS THAN (202605),
    PARTITION p202605 VALUES LESS THAN (202606),
    PARTITION p202606 VALUES LESS THAN (202607),
    PARTITION p202607 VALUES LESS THAN (202608),
    PARTITION p202608 VALUES LESS THAN (202609),
    PARTITION p202609 VALUES LESS THAN (202610),
    PARTITION p202610 VALUES LESS THAN (202611),
    PARTITION p202611 VALUES LESS THAN (202612),
    PARTITION p202612 VALUES LESS THAN (202701),
    PARTITION p202701 VALUES LESS THAN (202702),
    PARTITION p202702 VALUES LESS THAN (202703),
    PARTITION p202703 VALUES LESS THAN (202704),
    PARTITION p202704 VALUES LESS THAN (202705),
    PARTITION p202705 VALUES LESS THAN (202706),
    PARTITION p202706 VALUES LESS THAN (202707),
    PARTITION p202707 VALUES LESS THAN (202708),
    PARTITION p202708 VALUES LESS THAN (202709),
    PARTITION p202709 VALUES LESS THAN (202710),
    PARTITION p202710 VALUES LESS THAN (202711),
    PARTITION p202711 VALUES LESS THAN (202712),
    PARTITION p202712 VALUES LESS THAN MAXVALUE
);

SET FOREIGN_KEY_CHECKS = 1;