# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-12 06:09
from __future__ import unicode_literals

import django.db.models.deletion
import universal_notifications.backends.twilio.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('universal_notifications', '0002_device'),
    ]

    operations = [
        migrations.CreateModel(
            name='Phone',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('number', models.CharField(max_length=20, unique=True)),
                ('rate', models.IntegerField(default=6, verbose_name=b'Messages rate')),
                ('used_count', models.IntegerField(default=0)),
            ],
            options={
                'ordering': ['number'],
            },
        ),
        migrations.CreateModel(
            name='PhonePendingMessages',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('from_phone', models.CharField(db_index=True, max_length=30)),
                ('priority', models.IntegerField(default=9999)),
            ],
        ),
        migrations.CreateModel(
            name='PhoneReceived',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('media', models.CharField(blank=True, max_length=255, null=True)),
                ('type', models.CharField(choices=[(b'voice', b'voice'), (b'text', b'Text')], default=b'text', max_length=35)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('sms_id', models.CharField(blank=True, max_length=50)),
                ('is_opt_out', models.BooleanField(default=False)),
            ],
            options={
                'verbose_name': 'Received Message',
                'verbose_name_plural': 'Received Messages',
            },
        ),
        migrations.CreateModel(
            name='PhoneReceivedRaw',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('status', models.CharField(choices=[(b'pending', b'Pending'), (b'pass', b'Pass'), (b'fail', b'Fail'), (b'rejected', b'Rejected')], db_index=True, default=b'pending', max_length=35)),
                ('data', universal_notifications.backends.twilio.fields.JSONField()),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('exception', models.TextField(blank=True)),
            ],
        ),
        migrations.CreateModel(
            name='PhoneReceiver',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('number', models.CharField(db_index=True, max_length=20)),
                ('service_number', models.CharField(max_length=20)),
                ('is_blocked', models.BooleanField(default=False)),
            ],
            options={
                'ordering': ['number'],
            },
        ),
        migrations.CreateModel(
            name='PhoneSent',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('sms_id', models.CharField(blank=True, max_length=34)),
                ('status', models.CharField(choices=[(b'pending', b'Pending'), (b'queued', b'Queued'), (b'failed', b'failed'), (b'sent', b'sent'), (b'no_answer', b'no answer from twilio'), (b'delivered', b'delivered'), (b'undelivered', b'undelivered')], default=b'pending', max_length=35)),
                ('twilio_error_code', models.CharField(blank=True, max_length=100, null=True)),
                ('twilio_error_message', models.TextField(blank=True, null=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('media_raw', models.CharField(blank=True, max_length=255, null=True)),
                ('media', models.CharField(blank=True, max_length=255, null=True)),
                ('receiver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='universal_notifications.PhoneReceiver')),
            ],
            options={
                'verbose_name': 'Sent Message',
                'verbose_name_plural': 'Sent Messages',
            },
        ),
        migrations.AlterIndexTogether(
            name='phonereceiver',
            index_together=set([('number', 'service_number')]),
        ),
        migrations.AddField(
            model_name='phonereceived',
            name='raw',
            field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to='universal_notifications.PhoneReceivedRaw'),
        ),
        migrations.AddField(
            model_name='phonereceived',
            name='receiver',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='universal_notifications.PhoneReceiver'),
        ),
        migrations.AddField(
            model_name='phonependingmessages',
            name='message',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='universal_notifications.PhoneSent'),
        ),
    ]
