def migrate(self):
        trigger_dbs = self._get_trigger_with_parameters()
        for trigger_db in trigger_dbs:
            trigger_ref = trigger_db.get_reference().ref
            rules = self._get_rules_for_trigger(trigger_ref=trigger_ref)
            ref_count = len(rules)
            print('Updating Trigger %s to ref_count %s' % (trigger_ref, ref_count))
            self._update_trigger_ref_count(trigger_db=trigger_db, ref_count=ref_count)
Will migrate all Triggers that should have ref_count to have the right ref_count.
dataset/ETHPy150Open StackStorm/st2/tools/migrate_triggers_to_include_ref_count.py/TriggerMigrator.migrate