# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    constraint_args_step = {
        'table': 'workshops_workshopstep',
        'constraint': 'workshops_workshopstep_sort_order_workshop_id_key',
    }

    constraint_args_answer = {
        'table': 'workshops_workshopstepquestionanswer',
        'constraint': 'workshops_workshopstepquestionanswer_sort_order_question_id_key',
    }

    dependencies = [
        ('workshops', '0022_auto_20150916_1709'),
    ]

    operations = [
        migrations.RunSQL(
            'ALTER TABLE %(table)s DROP CONSTRAINT %(constraint)s' % constraint_args_step,

            'ALTER TABLE %(table)s ADD CONSTRAINT "%(constraint)s" '
            'UNIQUE (sort_order, workshop_id) DEFERRABLE INITIALLY DEFERRED;' % constraint_args_step,
        ),

        migrations.RunSQL(
            'ALTER TABLE %(table)s DROP CONSTRAINT %(constraint)s' % constraint_args_answer,

            'ALTER TABLE %(table)s ADD CONSTRAINT "%(constraint)s" '
            'UNIQUE (sort_order, question_id) DEFERRABLE INITIALLY DEFERRED;' % constraint_args_answer,
        ),
        migrations.AlterUniqueTogether(
            name='workshopstep',
            unique_together=set([('sort_order', 'workshop')]),
        ),
        migrations.AlterUniqueTogether(
            name='workshopstepquestionanswer',
            unique_together=set([('sort_order', 'question')]),
        ),
    ]
