-- SQL table definition
-- Generated from splitting a larger SQL file
-- Table: ai_articles
--

CREATE TABLE `ai_articles` (
  `id` int NOT NULL AUTO_INCREMENT,
  `batch_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '批次ID',
  `topic_type_id` int unsigned NOT NULL DEFAULT '0',
  `prompt_workflow_id` int unsigned NOT NULL DEFAULT '0',
  `topic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `title` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `departmentids` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `author_id` int DEFAULT NULL,
  `author_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `department_id` int DEFAULT NULL,
  `department_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `created_user_id` int NOT NULL DEFAULT '0',
  `review_user_id` int DEFAULT NULL,
  `publish_user_id` int DEFAULT NULL,
  `status` enum('topic','cover_image','generate','generate_failed','draft','pending_review','approved','rejected','published_review','published','failed') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'draft',
  `channel` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1=baidu|2=toutiao|3=weixin',
  `review_comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  `publish_time` timestamp NULL DEFAULT NULL,
  `baijiahao_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `baijiahao_status` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `word_count` int DEFAULT '0',
  `image_count` int DEFAULT '0',
  `coze_tag` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'Coze生成的标签',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `author_id` (`author_id`) USING BTREE,
  KEY `created_user_id` (`created_user_id`) USING BTREE,
  KEY `review_user_id` (`review_user_id`) USING BTREE,
  KEY `publish_user_id` (`publish_user_id`) USING BTREE,
  KEY `idx_articles_status_user_created` (`status`,`created_user_id`,`created_at` DESC),
  KEY `idx_articles_status_created` (`status`,`created_at` DESC),
  KEY `idx_articles_status` (`status`),
  KEY `idx_articles_created_at` (`created_at` DESC),
  KEY `idx_status_id_author` (`status`,`id`,`author_id`),
  KEY `idx_articles_updated_at` (`updated_at` DESC) USING BTREE,
  KEY `idx_articles_status_prompt_topic_id` (`status`,`prompt_workflow_id`,`topic`,`id`),
  KEY `idx_status_author_updated_id` (`status`,`author_id`,`updated_at`,`id`),
  KEY `idx_author_status_updated_id` (`author_id`,`status`,`updated_at`,`id`),
  CONSTRAINT `ai_articles_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `ai_authors` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ai_articles_ibfk_2` FOREIGN KEY (`created_user_id`) REFERENCES `ai_users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ai_articles_ibfk_3` FOREIGN KEY (`review_user_id`) REFERENCES `ai_users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `ai_articles_ibfk_4` FOREIGN KEY (`publish_user_id`) REFERENCES `ai_users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=535975 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
