SET FOREIGN_KEY_CHECKS=0;

-- 
delete from kpi_c_report_ims WHERE created_at <= '2025-08-15';
delete from kpi_c_report_upf WHERE created_at <= '2025-08-15';
delete from kpi_c_report_udm WHERE created_at <= '2025-08-15';
delete from kpi_c_report_smf WHERE created_at <= '2025-08-15';
delete from kpi_c_report_pcf WHERE created_at <= '2025-08-15';
delete from kpi_c_report_amf WHERE created_at <= '2025-08-15';
delete from kpi_c_report_ausf WHERE created_at <= '2025-08-15';
delete from kpi_report_ims WHERE created_at <= '2025-08-15';
delete from kpi_report_upf WHERE created_at <= '2025-08-15';
delete from kpi_report_udm WHERE created_at <= '2025-08-15';
delete from kpi_report_smf WHERE created_at <= '2025-08-15';
delete from kpi_report_pcf WHERE created_at <= '2025-08-15';
delete from kpi_report_amf WHERE created_at <= '2025-08-15';
delete from kpi_report_ausf WHERE created_at <= '2025-08-15';
delete from cdr_event_ims WHERE created_at <= '2025-08-15';
delete from cdr_event_smsc WHERE created_at <= '2025-08-15';
delete from cdr_event_smf WHERE created_at <= '2025-08-15';
delete from ue_event_amf WHERE created_at <= '2025-08-15';
delete from ue_event_mme WHERE created_at <= '2025-08-15';

ALTER TABLE `kpi_c_report_ims` ADD INDEX IF NOT EXISTS `idx_kpic_ims_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_ims 报表时间索引';
ALTER TABLE `kpi_c_report_upf` ADD INDEX IF NOT EXISTS `idx_kpic_upf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_upf 报表时间索引';
ALTER TABLE `kpi_c_report_udm` ADD INDEX IF NOT EXISTS `idx_kpic_udm_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_udm 报表时间索引';
ALTER TABLE `kpi_c_report_smf` ADD INDEX IF NOT EXISTS `idx_kpic_smf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_smf 报表时间索引';
ALTER TABLE `kpi_c_report_pcf` ADD INDEX IF NOT EXISTS `idx_kpic_pcf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_pcf 报表时间索引';
ALTER TABLE `kpi_c_report_amf` ADD INDEX IF NOT EXISTS `idx_kpic_amf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_amf 报表时间索引';
ALTER TABLE `kpi_c_report_ausf` ADD INDEX IF NOT EXISTS `idx_kpic_ausf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_c_report_ausf 报表时间索引';
ALTER TABLE `kpi_report_ims` ADD INDEX IF NOT EXISTS `idx_kpi_report_ims_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_ims 报表时间索引';
ALTER TABLE `kpi_report_upf` ADD INDEX IF NOT EXISTS `idx_kpi_report_upf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_upf 报表时间索引';
ALTER TABLE `kpi_report_udm` ADD INDEX IF NOT EXISTS `idx_kpi_report_udm_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_udm 报表时间索引';
ALTER TABLE `kpi_report_smf` ADD INDEX IF NOT EXISTS `idx_kpi_report_smf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_smf 报表时间索引';
ALTER TABLE `kpi_report_pcf` ADD INDEX IF NOT EXISTS `idx_kpi_report_pcf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_pcf 报表时间索引';
ALTER TABLE `kpi_report_amf` ADD INDEX IF NOT EXISTS `idx_kpi_report_amf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_amf 报表时间索引';
ALTER TABLE `kpi_report_ausf` ADD INDEX IF NOT EXISTS `idx_kpi_report_ausf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'kpi_report_ausf 报表时间索引';
ALTER TABLE `cdr_event_ims` ADD INDEX IF NOT EXISTS `idx_cdr_event_ims_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'cdr_event_ims 报表时间索引';
ALTER TABLE `cdr_event_smsc` ADD INDEX IF NOT EXISTS `idx_cdr_event_smsc_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'cdr_event_smsc 报表时间索引';
ALTER TABLE `cdr_event_smf` ADD INDEX IF NOT EXISTS `idx_cdr_event_smf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'cdr_event_smf 报表时间索引';
ALTER TABLE `ue_event_amf` ADD INDEX IF NOT EXISTS `idx_ue_event_amf_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'ue_event_amf 报表时间索引';
ALTER TABLE `ue_event_mme` ADD INDEX IF NOT EXISTS `idx_ue_event_mme_rc`(`rm_uid` DESC, `created_at` DESC) USING BTREE COMMENT 'ue_event_mme 报表时间索引';

SET FOREIGN_KEY_CHECKS = 1;