예제 #1
0
    def setUp(self):
        super(TestDocTypeMigrations, self).setUp()
        self.migration = Migrator(
            slug='user_db_migration',
            source_db_name=None,
            target_db_name=settings.NEW_USERS_GROUPS_DB,
            doc_types=(
                'Group',
                'CommCareUser',
            )
        )
        delete_all_docs_by_doc_type(self.migration.source_db, self.migration.doc_types)
        self.migration.target_db.delete_docs(_get_non_design_docs(self.migration.target_db))

        self.docs = [
            {'doc_type': 'CommCareUser', 'username': '******'},
            {'doc_type': 'CommCareUser', 'username': '******'},
            {'doc_type': 'Group', 'name': 'User Group'},
            {'doc_type': 'Group-Deleted', 'name': 'Deleted User Group'},
        ]
        results = self.migration.source_db.bulk_save(self.docs)
        for doc, result in zip(self.docs, results):
            doc['_id'] = result['id']
            doc['_rev'] = result['rev']
        _sort_by_doc_id(self.docs)
예제 #2
0
    def setUp(self):
        super(TestDocTypeMigrations, self).setUp()
        self.migration = Migrator(slug='user_db_migration',
                                  source_db_name=None,
                                  target_db_name=settings.NEW_USERS_GROUPS_DB,
                                  doc_types=(
                                      'Group',
                                      'CommCareUser',
                                  ))
        delete_all_docs_by_doc_type(self.migration.source_db,
                                    self.migration.doc_types)
        self.migration.target_db.delete_docs(
            _get_non_design_docs(self.migration.target_db))

        self.docs = [
            {
                'doc_type': 'CommCareUser',
                'username': '******'
            },
            {
                'doc_type': 'CommCareUser',
                'username': '******',
                '_attachments': {
                    "greeting.txt": {
                        "content_type": "text/plain",
                        "data": base64.b64encode("hi"),
                        "digest": "md5-QTVOnBwGnrw6Tx9YG1ZRyA==",
                        "revpos": 1,
                    }
                }
            },
            {
                'doc_type': 'Group',
                'name': 'User Group'
            },
            {
                'doc_type': 'Group-Deleted',
                'name': 'Deleted User Group'
            },
        ]
        results = self.migration.source_db.bulk_save(self.docs)
        for doc, result in zip(self.docs, results):
            doc['_id'] = result['id']
            doc['_rev'] = result['rev']
        _sort_by_doc_id(self.docs)
예제 #3
0
from django.conf import settings
from corehq.doctypemigrations.migrator import Migrator

users_migration = Migrator(slug='user_db_migration',
                           source_db_name=None,
                           target_db_name=settings.NEW_USERS_GROUPS_DB,
                           doc_types=(
                               'Group',
                               'DeleteGroupRecord',
                               'UserRole',
                               'AdminUserRole',
                               'CommCareUser',
                               'WebUser',
                               'Invitation',
                               'DomainRemovalRecord',
                               'OrgRemovalRecord',
                           ))

fixtures_migration = Migrator(slug='fixtures',
                              source_db_name=None,
                              target_db_name=settings.NEW_FIXTURES_DB,
                              doc_types=(
                                  'FixtureDataType',
                                  'FixtureDataItem',
                                  'FixtureOwnership',
                              ))

domains_migration = Migrator(slug='domains',
                             source_db_name=None,
                             target_db_name=settings.NEW_DOMAINS_DB,
                             doc_types=('Domain', ))