# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-16 20:59
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

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

    def bootstrap_polls(apps, schema_editor):
        # We can't import the Person model directly as it may be a newer
        # version than this migration expects. We use the historical version.
        Question = apps.get_model("voting", "Question")
        Choice = apps.get_model("voting", "Choice")
        name = "Cats or Dogs?"
        try:
            # if the question already exists, then no need to do anything.
            Question.objects.get(question_text=name)
        except Question.DoesNotExist:
            # does not exist, add it.
            question = Question.objects.create(question_text=name)
            Choice.objects.create(question=question, choice_text="Cats")
            Choice.objects.create(question=question, choice_text="Dogs")

    operations = [
        migrations.RunPython(bootstrap_polls),
    ]
