Beispiel #1
0
    def test_icds_db_citus(self):
        with override_settings(CUSTOM_DB_ROUTING={}):
            self.assertIs(True, allow_migrate(DEFAULT_DB_ALIAS, 'icds_reports'))

        # map to reporting DB alias
        with override_settings(CUSTOM_DB_ROUTING={'custom_app': 'icds-ucr-citus'}), \
             override_engine('icds-ucr-citus', '', db_alias='icds-ucr'):
                self.assertIs(False, allow_migrate(DEFAULT_DB_ALIAS, 'custom_app'))
                self.assertIs(True, allow_migrate('icds-ucr', 'custom_app'))

        # map to DB alias
        with override_settings(CUSTOM_DB_ROUTING={'custom_app': 'icds-ucr'}):
            self.assertIs(True, allow_migrate('icds-ucr', 'custom_app'))
Beispiel #2
0
 def database_forwards(self, app_label, schema_editor, from_state, to_state):
     db_alias = schema_editor.connection.alias
     if allow_migrate(db_alias, app_label):
         if not self.rendered_forwards:
             self.sql = self._render_template(self.sql)
             self.rendered_forwards = True
         super(RunSqlLazy, self).database_forwards(app_label, schema_editor, from_state, to_state)
Beispiel #3
0
 def database_forwards(self, app_label, schema_editor, from_state, to_state):
     db_alias = schema_editor.connection.alias
     if allow_migrate(db_alias, app_label):
         if not self.rendered_forwards:
             self.sql = self._render_template(self.sql)
             self.rendered_forwards = True
         super(RunSqlLazy, self).database_forwards(app_label, schema_editor, from_state, to_state)
Beispiel #4
0
 def database_backwards(self, app_label, schema_editor, from_state,
                        to_state):
     db_alias = schema_editor.connection.alias
     if allow_migrate(db_alias, app_label):
         super(HqOpMixin, self).database_backwards(app_label, schema_editor,
                                                   from_state, to_state)
Beispiel #5
0
 def test_synclogs_non_partitioned(self):
     self.assertIs(False, allow_migrate('synclogs', 'accounting'))
     self.assertIs(True, allow_migrate(None, 'accounting'))
     self.assertIs(True, allow_migrate('default', 'accounting'))
Beispiel #6
0
 def test_icds_db(self, mock):
     mock.return_value = None
     self.assertIs(False, allow_migrate('default', ICDS_REPORTS_APP))
     mock.return_value = 'icds'
     self.assertIs(False, allow_migrate('default', ICDS_REPORTS_APP))
     self.assertIs(True, allow_migrate('icds', ICDS_REPORTS_APP))
Beispiel #7
0
 def test_synclogs_db(self):
     self.assertIs(False, allow_migrate('default', SYNCLOGS_APP))
     self.assertIs(True, allow_migrate('synclogs', SYNCLOGS_APP))
Beispiel #8
0
 def test_warehouse_migrate(self):
     self.assertIs(True, allow_migrate(WAREHOUSE_DB, 'warehouse'))
     with patch('corehq.sql_db.routers.partition_config', MagicMock()):
         self.assertIs(False, allow_migrate(WAREHOUSE_DB, 'couchforms'))
     self.assertIs(False, allow_migrate('default', 'warehouse'))
Beispiel #9
0
 def database_backwards(self, app_label, schema_editor, from_state, to_state):
     db_alias = schema_editor.connection.alias
     if allow_migrate(db_alias, app_label):
         super(HqOpMixin, self).database_backwards(app_label, schema_editor, from_state, to_state)
Beispiel #10
0
 def test_synclogs_non_partitioned(self):
     self.assertIs(False, allow_migrate('synclogs', 'accounting'))
     self.assertIs(True, allow_migrate(None, 'accounting'))
     self.assertIs(True, allow_migrate(DEFAULT_DB_ALIAS, 'accounting'))
Beispiel #11
0
 def test_synclogs_db(self):
     self.assertIs(False, allow_migrate(DEFAULT_DB_ALIAS, SYNCLOGS_APP))
     self.assertIs(True, allow_migrate('synclogs', SYNCLOGS_APP))
Beispiel #12
0
 def test_icds_db_citus(self, mock):
     mock.return_value = None
     self.assertIs(False, allow_migrate(DEFAULT_DB_ALIAS, ICDS_REPORTS_APP))
     mock.return_value = 'icds'
     self.assertIs(False, allow_migrate(DEFAULT_DB_ALIAS, ICDS_REPORTS_APP))
     self.assertIs(True, allow_migrate('icds', ICDS_REPORTS_APP))
Beispiel #13
0
 def test_synclogs_non_partitioned(self):
     self.assertIs(False, allow_migrate('synclogs', 'accounting'))
     self.assertIs(True, allow_migrate(None, 'accounting'))
     self.assertIs(True, allow_migrate('default', 'accounting'))
Beispiel #14
0
 def test_icds_db(self, mock):
     mock.return_value = None
     self.assertIs(False, allow_migrate('default', ICDS_REPORTS_APP))
     mock.return_value = 'icds'
     self.assertIs(False, allow_migrate('default', ICDS_REPORTS_APP))
     self.assertIs(True, allow_migrate('icds', ICDS_REPORTS_APP))
Beispiel #15
0
 def test_synclogs_db(self):
     self.assertIs(False, allow_migrate('default', SYNCLOGS_APP))
     self.assertIs(True, allow_migrate('synclogs', SYNCLOGS_APP))
Beispiel #16
0
 def test_warehouse_migrate(self):
     self.assertIs(True, allow_migrate(WAREHOUSE_DB, 'warehouse'))
     with patch('corehq.sql_db.routers.partition_config', MagicMock()):
         self.assertIs(False, allow_migrate(WAREHOUSE_DB, 'couchforms'))
     self.assertIs(False, allow_migrate('default', 'warehouse'))