-- ******************************************************************
-- 表 kku_cleanup_sql_backups 的创建SQL
-- 对应的Model: App\Module\Cleanup\Models\CleanupSqlBackup
-- 警告: 此文件由系统自动生成，禁止修改！
-- ******************************************************************

CREATE TABLE `kku_cleanup_sql_backups` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `backup_id` bigint unsigned NOT NULL COMMENT '备份记录ID',
  `table_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表名',
  `sql_content` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'INSERT语句内容',
  `records_count` bigint unsigned NOT NULL DEFAULT '0' COMMENT '记录数量',
  `content_size` bigint unsigned NOT NULL DEFAULT '0' COMMENT '内容大小(字节)',
  `content_hash` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '内容SHA256哈希',
  `backup_conditions` json DEFAULT NULL COMMENT '备份条件',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_backup_id` (`backup_id`),
  KEY `idx_table_name` (`table_name`),
  KEY `idx_records_count` (`records_count`),
  KEY `idx_content_size` (`content_size`),
  CONSTRAINT `kku_cleanup_sql_backups_ibfk_1` FOREIGN KEY (`backup_id`) REFERENCES `kku_cleanup_backups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='SQL备份表';
