# Generated by Django 2.1.1 on 2018-09-24 08:55

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [("coursera", "0002_create_course_membership_view")]

    operations = [
        migrations.RunSQL(
            sql=[
                """
                CREATE MATERIALIZED VIEW course_branch_modules_view
                AS
                SELECT
                MD5(MD5(course_branch_id) || course_module_id)::varchar(50) as module_id,
                course_branch_id,
                course_module_id,
                course_branch_module_order,
                course_branch_module_name,
                course_branch_module_desc
                FROM
                course_branch_modules;
                """,
                """
                CREATE UNIQUE INDEX ON course_branch_modules_view (module_id)
                """,
                """
                CREATE INDEX ON course_branch_modules_view (course_branch_id)
                """,
            ],
            reverse_sql="""
            DROP MATERIALIZED VIEW IF EXISTS course_branch_modules_view
            """,
        )
    ]
