Beispiel #1
0
def create_update_pl_proxy_config():
    if not (settings.UNIT_TESTING and settings.USE_PARTITIONED_DATABASE):
        return noop_migration()

    sql_statements = get_sql_to_create_pl_proxy_cluster(plproxy_config)
    drop_server_sql = get_drop_server_sql(plproxy_config.cluster_name)
    return migrations.RunSQL('\n'.join(sql_statements), drop_server_sql)
Beispiel #2
0
def create_update_pl_proxy_config():
    if not (settings.UNIT_TESTING and settings.USE_PARTITIONED_DATABASE):
        return noop_migration()

    drop_server_sql = get_drop_server_sql()
    sql_statements = [
        get_pl_proxy_server_config_sql(partition_config.get_shards()),
        get_user_mapping_sql()
    ]

    return migrations.RunSQL('\n'.join(sql_statements), drop_server_sql)
class Migration(migrations.Migration):

    dependencies = [
        ('sql_accessors', '0055_set_form_modified_on'),
    ]

    operations = [
        # this originally installed the hashlib extension in production as well
        # but commcare-cloud does that where possible already
        # and Amazon RDS doesn't allow it
        # Todo: Move this to testing harness, doesn't really belong here.
        # See https://github.com/dimagi/commcare-hq/pull/21627#pullrequestreview-149807976
        migrations.RunSQL('CREATE EXTENSION IF NOT EXISTS hashlib',
                          'DROP EXTENSION hashlib')
        if settings.UNIT_TESTING else noop_migration()
    ]
Beispiel #4
0
    def get_migration(self, forward_template, reverse_template=NOOP, testing_only=False):
        if testing_only and not settings.UNIT_TESTING:
            return noop_migration()

        if isinstance(forward_template, SQL):
            forward_path = forward_template
        else:
            forward_path = os.path.join(self.base_path, forward_template)

        if reverse_template is NOOP:
            reverse_path = NOOP
        elif reverse_template is None:
            reverse_path = None  # make the migration non-reversible
        elif isinstance(reverse_template, SQL):
            reverse_path = reverse_template
        else:
            reverse_path = os.path.join(self.base_path, reverse_template)

        return RunSqlLazy(
            forward_path,
            reverse_path,
            self.template_context
        )