SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS `lb_goods`;
CREATE TABLE `lb_goods` (
  `id`           BIGINT         NOT NULL COMMENT '商品ID（外部系统主键）',
  `tenant_id`    CHAR(36)       DEFAULT NULL COMMENT '租户id',
  `old_id`       BIGINT         DEFAULT NULL COMMENT '旧商品ID（迁移/关联用）',
  `user_id`      BIGINT         DEFAULT NULL COMMENT '所属用户ID',
  `title`        VARCHAR(200)   DEFAULT NULL COMMENT '商品标题',
  `image`        VARCHAR(512)   DEFAULT NULL COMMENT '商品图片路径',
  `price`        DECIMAL(12, 2) NOT NULL DEFAULT 0.00 COMMENT '单价',
  `total_money`  DECIMAL(12, 2) NOT NULL DEFAULT 0.00 COMMENT '总金额',
  `quantity`     VARCHAR(64)    DEFAULT NULL COMMENT '数量描述（如：≈6盒）',
  `seller_id`    BIGINT         DEFAULT NULL COMMENT '卖家用户ID',
  `is_show`      TINYINT        NOT NULL DEFAULT 1 COMMENT '是否展示：0否 1是',
  `status`       TINYINT        NOT NULL DEFAULT -1 COMMENT '状态',
  `current_page` INT            DEFAULT NULL COMMENT '当前页码（同步来源页）',
  `created_at`   DATETIME       DEFAULT NULL COMMENT '创建时间',
  `updated_at`   DATETIME       DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_old_id` (`old_id`) USING BTREE,
  KEY `idx_user_id` (`user_id`) USING BTREE,
  KEY `idx_seller_id` (`seller_id`) USING BTREE,
  KEY `idx_status_is_show` (`status`, `is_show`) USING BTREE,
  KEY `idx_created_at` (`created_at`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci
  COMMENT = '货品表'
  ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
