<commit_before>import os
import uuid
from datetime import datetime

import corehq.apps.couch_sql_migration.constants as const
import settings
from casexml.apps.case.models import CommCareCase
from casexml.apps.case.xform import get_all_extensions_to_close, CaseProcessingResult
from corehq.apps.domain.models import Domain
from corehq.apps.tzmigration import force_phone_timezones_should_be_processed
from corehq.form_processor.backends.sql.dbaccessors import CaseAccessorSQL, doc_type_to_state
from corehq.form_processor.backends.sql.processor import FormProcessorSQL
from corehq.form_processor.interfaces.processor import FormProcessorInterface, ProcessedForms
from corehq.form_processor.models import (
    XFormInstanceSQL, XFormOperationSQL, XFormAttachmentSQL, CommCareCaseSQL,
    CaseTransaction, RebuildWithReason, CommCareCaseIndexSQL
)
from corehq.form_processor.submission_post import CaseStockProcessingResult
from corehq.form_processor.utils import adjust_datetimes
from corehq.form_processor.utils import should_use_sql_backend
from corehq.form_processor.utils.general import set_local_domain_sql_backend_override, \
    clear_local_domain_sql_backend_override
from couchforms.models import XFormInstance, doc_types
from dimagi.utils.couch.undo import DELETED_SUFFIX
from fluff.management.commands.ptop_reindexer_fluff import ReindexEventHandler
from pillowtop.reindexer.change_providers.couch import CouchDomainDocTypeChangeProvider


def do_couch_to_sql_migration(domain):
    # (optional) collect some information about the domain's cases and forms for cross-checking
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(domain).migrate()
    # (optional) compare the information collected to the information at the beginning<commit_msg>remove comments<commit_after>import os
import uuid
from datetime import datetime

import corehq.apps.couch_sql_migration.constants as const
import settings
from casexml.apps.case.models import CommCareCase
from casexml.apps.case.xform import get_all_extensions_to_close, CaseProcessingResult
from corehq.apps.domain.models import Domain
from corehq.apps.tzmigration import force_phone_timezones_should_be_processed
from corehq.form_processor.backends.sql.dbaccessors import CaseAccessorSQL, doc_type_to_state
from corehq.form_processor.backends.sql.processor import FormProcessorSQL
from corehq.form_processor.interfaces.processor import FormProcessorInterface, ProcessedForms
from corehq.form_processor.models import (
    XFormInstanceSQL, XFormOperationSQL, XFormAttachmentSQL, CommCareCaseSQL,
    CaseTransaction, RebuildWithReason, CommCareCaseIndexSQL
)
from corehq.form_processor.submission_post import CaseStockProcessingResult
from corehq.form_processor.utils import adjust_datetimes
from corehq.form_processor.utils import should_use_sql_backend
from corehq.form_processor.utils.general import set_local_domain_sql_backend_override, \
    clear_local_domain_sql_backend_override
from couchforms.models import XFormInstance, doc_types
from dimagi.utils.couch.undo import DELETED_SUFFIX
from fluff.management.commands.ptop_reindexer_fluff import ReindexEventHandler
from pillowtop.reindexer.change_providers.couch import CouchDomainDocTypeChangeProvider


def do_couch_to_sql_migration(domain):
    set_local_domain_sql_backend_override(domain)
    CouchSqlDomainMigrator(domain).migrate()
{'fraction_non_alphanumeric': 0.04560260586319218, 'fraction_numerical': 0.0, 'mean_word_length': 8.179347826086957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4664617', 'n_tokens_mistral': 982, 'n_tokens_neox': 973, 'n_words': 209}