CREATE TABLE `industry` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '行业分类主键',
  `parent_id` bigint(20) NOT NULL,
  `primary_name` varchar(200) NOT NULL COMMENT '一级行业名称',
  `secondary_name` varchar(200) DEFAULT NULL COMMENT '二级行业名称',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COMMENT='行业分类表';


CREATE TABLE `draft_industry_rel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `draft_id` bigint(20) NOT NULL COMMENT '资讯草稿ID',
  `industry_id` bigint(20) NOT NULL COMMENT '行业分类ID',
  PRIMARY KEY (`id`),
  KEY `IDX_DRAFT_ID` (`draft_id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COMMENT='资讯草稿行业关联表';

CREATE TABLE `news_industry_rel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '资讯精选行业关联表主键',
  `news_id` bigint(20) NOT NULL COMMENT '资讯ID',
  `industry_id` bigint(20) NOT NULL COMMENT '行业分类ID',
  PRIMARY KEY (`id`),
  KEY `IDX_NEWS_ID` (`news_id`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COMMENT='资讯精选行业关联表';

alter table news add column `newsinfo_id` varchar(20) character set utf8mb4 collate utf8mb4_unicode_ci;
alter table news_tags add column `newsinfo_id` varchar(20) COLLATE utf8mb4_unicode_ci GENERATED ALWAYS AS (cast(`news_id` as char charset utf8mb4)) VIRTUAL;
CREATE INDEX idx_news_tags_newsinfo_id ON news_tags(newsinfo_id);
