# Generated by Django 2.1.2 on 2018-10-23 10:59

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [("coursera", "0038_create_heartbeat_index")]

    operations = [
        migrations.RunSQL(
            [
                """
                CREATE MATERIALIZED VIEW
                    course_payments_view
                AS
                SELECT
                    MD5(MD5(course_id) || eitdigital_user_id)::varchar(50) as id,
                    course_id,
                    eitdigital_user_id,
                    met_payment_condition,
                    was_payment,
                    was_finaid_grant,
                    was_group_sponsored
                FROM
                    users_courses__certificate_payments
                """,
                """
                CREATE UNIQUE INDEX ON course_payments_view (id)
                """,
                """
                CREATE INDEX ON course_payments_view (course_id)
                """,
                """
                CREATE INDEX ON course_payments_view (eitdigital_user_id)
                """,
            ],
            reverse_sql="DROP MATERIALIZED VIEW IF EXISTS course_payments_view",
        )
    ]
