示例#1
0
def get_all_disha_migrations():
    sql_views = [
        'agg_awc_monthly.sql',
        'agg_ccs_record_monthly.sql',
        'agg_child_health_monthly.sql',
        'disha_indicators.sql',
    ]
    migrator = RawSQLMigration(('custom', 'icds_reports', 'migrations', 'sql_templates', 'database_views'))
    operations = []
    for view in sql_views:
        operations.append(migrator.get_migration(view))
    return operations
示例#2
0
def get_view_migrations():
    sql_views = [
        'awc_location_months.sql',
        'agg_awc_monthly.sql',
        'agg_ccs_record_monthly.sql',
        'agg_child_health_monthly.sql',
        'daily_attendance.sql',
        'agg_awc_daily.sql',
        'child_health_monthly.sql',
        'disha_indicators.sql',
        'ccs_record_monthly_view.sql',
        'agg_ls_monthly.sql',
        'service_delivery_monthly.sql',
        'aww_incentive_report_monthly.sql',
    ]
    migrator = RawSQLMigration(('custom', 'icds_reports', 'migrations', 'sql_templates', 'database_views'))
    operations = []
    for view in sql_views:
        operations.append(migrator.get_migration(view))
    return operations
def get_disha_migration():
    migrator = RawSQLMigration(('custom', 'icds_reports', 'migrations', 'sql_templates', 'database_views'))
    return migrator.get_migration('disha_indicators.sql')
# Generated by Django 1.11.9 on 2018-01-23 22:40
from corehq.sql_db.operations import RawSQLMigration
from django.db import migrations

from custom.icds_reports.const import SQL_TEMPLATES_ROOT

migrator = RawSQLMigration((SQL_TEMPLATES_ROOT,))


class Migration(migrations.Migration):

    dependencies = [
        ('icds_reports', '0032_create_datasource_views'),
    ]

    operations = [
        migrator.get_migration('update_tables16.sql'),
    ]
示例#5
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations
from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(
    ('custom', 'icds_reports', 'migrations', 'sql_templates'))


class Migration(migrations.Migration):

    dependencies = []

    operations = [
        migrator.get_migration('create_tables_and_views.sql'),
    ]
示例#6
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations

from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(
    ('corehq', 'sql_proxy_accessors', 'sql_templates'),
    {'PL_PROXY_CLUSTER_NAME': settings.PL_PROXY_CLUSTER_NAME})


class Migration(migrations.Migration):

    dependencies = [
        ('sql_proxy_accessors', '0001_initial'),
    ]

    operations = [
        migrator.get_migration('get_case_last_modified_dates.sql'),
        migrator.get_migration('get_extension_case_ids.sql'),
        migrator.get_migration('case_has_transactions_since_sync.sql'),
        migrator.get_migration('get_all_reverse_indices.sql'),
        migrator.get_migration('get_case_ids_modified_with_owner_since.sql'),
    ]
示例#7
0
from django.db import migrations

from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(
    ('corehq', 'form_processor', 'migrations', 'sql_templates'))


class Migration(migrations.Migration):

    dependencies = [
        ('form_processor', '0079_add_xmlns_index'),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(database_operations=[
            migrator.get_migration('migrate_delta_1_add_column.sql'),
        ]),
    ]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations

from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(('corehq', 'sql_accessors', 'sql_templates'), {})


class Migration(migrations.Migration):

    dependencies = [
        ('sql_accessors', '0038_save_case_deletion_fields'),
    ]

    operations = [
        migrator.get_migration('get_all_forms_received_since_2.sql'),
        migrator.get_migration('get_all_ledger_values_modified_since_2.sql'),
    ]
示例#9
0
# Generated by Django 1.11.16 on 2019-06-17 16:38
from corehq.sql_db.operations import RawSQLMigration
from django.db import migrations

from custom.icds_reports.const import SQL_TEMPLATES_ROOT

migrator = RawSQLMigration((SQL_TEMPLATES_ROOT, 'database_views'))


class Migration(migrations.Migration):

    dependencies = [
        ('icds_reports', '0131_update_views_For_thr_colums'),
    ]

    operations = []
示例#10
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations

from corehq.form_processor.models import CaseTransaction
from corehq.sql_db.operations import RawSQLMigration, HqRunSQL

migrator = RawSQLMigration(('corehq', 'sql_accessors', 'sql_templates'), {
    'TRANSACTION_TYPE_FORM': CaseTransaction.TYPE_FORM
})


class Migration(migrations.Migration):

    dependencies = [
        ('sql_accessors', '0024_update_save_ledger_values'),
    ]

    operations = [
        HqRunSQL(
            "DROP FUNCTION IF EXISTS get_ledger_values_for_cases(TEXT[])",
            "SELECT 1"
        ),
        migrator.get_migration('get_ledger_values_for_cases.sql'),
    ]
示例#11
0
from django.db import migrations

from corehq.form_processor.models import XFormInstanceSQL, XFormOperationSQL, CaseTransaction
from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(
    ('corehq', 'sql_accessors', 'sql_templates'), {
        'FORM_STATE_ARCHIVED': XFormInstanceSQL.ARCHIVED,
        'FORM_STATE_NORMAL': XFormInstanceSQL.NORMAL,
        'FORM_OPERATION_ARCHIVE': XFormOperationSQL.ARCHIVE,
        'FORM_OPERATION_UNARCHIVE': XFormOperationSQL.UNARCHIVE,
        'TRANSACTION_TYPE_LEDGER': CaseTransaction.TYPE_LEDGER,
        'TRANSACTION_TYPE_FORM': CaseTransaction.TYPE_FORM,
    })


class Migration(migrations.Migration):

    dependencies = []

    operations = [
        # no longer required
        migrations.RunSQL(
            'DROP FUNCTION IF EXISTS deprecate_form(TEXT, TEXT, TIMESTAMP)',
            'SELECT 1'),
        # replaced by save_new_form_and_related_models
        migrations.RunSQL(
            'DROP FUNCTION IF EXISTS save_new_form_with_attachments(form_processor_xforminstancesql, form_processor_xformattachmentsql[])',
            'SELECT 1'),
        # signature changed
        migrations.RunSQL(
示例#12
0
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-01-14 16:51
from __future__ import absolute_import
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models, ProgrammingError

from corehq.sql_db.operations import HqRunPython, noop_migration_fn, RawSQLMigration
from corehq.sql_db.migrations import partitioned

migrator = RawSQLMigration(('corehq', 'blobs', 'sql_templates'), {})


def _drop_empty_default_blobmeta_table(apps, schema_editor):
    """Drop unused table in partitioned environment 'default' database

    The table is only dropped if it is empty (as it should be).
    """
    if schema_editor.connection.alias != "default" or not settings.USE_PARTITIONED_DATABASE:
        return

    with schema_editor.connection.cursor() as cursor:
        try:
            cursor.execute("SELECT COUNT(*) FROM blobs_blobmeta")
        except ProgrammingError as err:
            if '"blobs_blobmeta" does not exist' in repr(err):
                return
        blob_count = cursor.fetchone()[0]
        if blob_count > 0:
            # Unexpected state! Do not drop non-empty table.
from django.db import migrations

from corehq.form_processor.models import CommCareCaseIndexSQL
from corehq.sql_db.operations import RawSQLMigration

migrator = RawSQLMigration(('corehq', 'sql_accessors', 'sql_templates'), {
    'RELATIONSHIP_TYPE_EXTENSION': CommCareCaseIndexSQL.EXTENSION
})


class Migration(migrations.Migration):

    dependencies = [
        ('sql_accessors', '0001_initial')
    ]

    operations = [
        migrator.get_migration('get_case_last_modified_dates.sql'),
        migrator.get_migration('case_has_transactions_since_sync.sql'),
    ]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations
from corehq.sql_db.operations import RawSQLMigration
from corehq.form_processor.models import XFormInstanceSQL

migrator = RawSQLMigration(('corehq', 'sql_accessors', 'sql_templates'),
                           {'FORM_STATE_DELETED': XFormInstanceSQL.DELETED})


class Migration(migrations.Migration):

    dependencies = [
        ('sql_accessors', '0034_update_reindex_functions'),
    ]

    operations = [
        migrator.get_migration('soft_undelete_cases.sql'),
        migrator.get_migration('soft_undelete_forms.sql'),
    ]
def get_disha_migration():
    migrator = RawSQLMigration(('custom', 'icds_reports', 'migrations',
                                'sql_templates', 'database_views'))
    return migrator.get_migration('disha_indicators.sql')