@@ -0,0 +1,933 @@
+from django.core.management import BaseCommand%0A%0Afrom corehq.form_processor.interfaces.dbaccessors import CaseAccessors%0Afrom corehq.apps.hqcase.utils import update_case%0Afrom custom.enikshay.model_migration_sets import EpisodeFacilityIDMigration%0A%0A%0Aclass Command(BaseCommand):%0A%0A    def add_arguments(self, parser):%0A        parser.add_argument('domain')%0A        parser.add_argument('episode_case_ids', nargs='*')%0A%0A    def handle(self, domain, episode_case_ids, **options):%0A        case_accessor = CaseAccessors(domain)%0A%0A        if not episode_case_ids:%0A            episode_case_ids = case_accessor.get_case_ids_in_domain(type='episode')%0A%0A        for episode_case_id in episode_case_ids:%0A            episode_case = case_accessor.get_case(episode_case_id)%0A            update_json = EpisodeFacilityIDMigration(domain, episode_case).update_json()%0A            if update_json:%0A                update_case(domain, episode_case_id, update_json)%0A

add once-off management command for episode facility id migration