-- Master DB: company_tag_binding_exec_stats (defensive, tenant DB is primary) CREATE TABLE IF NOT EXISTS `company_tag_binding_exec_stats` ( `id` BIGINT NOT NULL AUTO_INCREMENT, `company_id` BIGINT NOT NULL COMMENT 'company id', `binding_id` BIGINT NOT NULL COMMENT 'binding id', `rel_count` INT NOT NULL DEFAULT 0, `task_pending` INT NOT NULL DEFAULT 0, `instance_running` INT NOT NULL DEFAULT 0, `stat_time` DATETIME NOT NULL, `create_time` DATETIME NULL, `update_time` DATETIME NULL, PRIMARY KEY (`id`), UNIQUE KEY `uk_company_binding` (`company_id`, `binding_id`), KEY `idx_company_stat_time` (`company_id`, `stat_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='tag binding execution stats';