# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-27 22:37
from __future__ import unicode_literals

import datetime
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_geo_db.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='City',
            fields=[
                ('city_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=50)),
                ('generated_name', models.CharField(blank=True, max_length=50, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Continent',
            fields=[
                ('continent_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=50, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Country',
            fields=[
                ('country_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('abbreviation', models.CharField(max_length=2, unique=True)),
                ('continent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.Continent')),
            ],
        ),
        migrations.CreateModel(
            name='GeoCoordinate',
            fields=[
                ('geocoordinate_id', models.AutoField(primary_key=True, serialize=False)),
                ('lat', models.DecimalField(decimal_places=5, max_digits=7)),
                ('lon', models.DecimalField(decimal_places=5, max_digits=8)),
                ('generated_name', models.CharField(blank=True, max_length=50, null=True)),
                ('lat_neg', models.BooleanField(default=False)),
                ('lat_tens', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lat_ones', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lat_tenths', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lat_hundredths', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lat_thousands', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_neg', models.BooleanField(default=False)),
                ('lon_hundreds', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_tens', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_ones', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_tenths', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_hundredths', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
                ('lon_thousands', django_geo_db.models.IntegerRangeField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Location',
            fields=[
                ('location_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(blank=True, max_length=30, null=True)),
                ('generated_name', models.CharField(blank=True, max_length=50, null=True)),
                ('city', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.City')),
                ('country', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.Country')),
                ('geocoordinate', models.ForeignKey(blank=True, help_text='This is a very specific location.', null=True, on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.GeoCoordinate')),
            ],
        ),
        migrations.CreateModel(
            name='State',
            fields=[
                ('state_id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('abbreviation', models.CharField(max_length=2, unique=True)),
                ('generated_name', models.CharField(blank=True, max_length=50, null=True)),
                ('country', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.Country')),
                ('geocoordinate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.GeoCoordinate')),
            ],
        ),
        migrations.CreateModel(
            name='UserLocation',
            fields=[
                ('user_location_id', models.AutoField(primary_key=True, serialize=False)),
                ('last_used', models.DateTimeField(blank=True, default=datetime.datetime.now)),
                ('user_created', models.BooleanField(default=True)),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.Location')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('last_used',),
            },
        ),
        migrations.CreateModel(
            name='Zipcode',
            fields=[
                ('zipcode_id', models.AutoField(primary_key=True, serialize=False)),
                ('zipcode', django_geo_db.models.IntegerRangeField(unique=True)),
                ('timezone', models.IntegerField()),
                ('generated_name', models.CharField(blank=True, max_length=50, null=True)),
                ('city', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.City')),
                ('geocoordinate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.GeoCoordinate')),
            ],
        ),
        migrations.AddField(
            model_name='location',
            name='state',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.State'),
        ),
        migrations.AddField(
            model_name='location',
            name='zipcode',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.Zipcode'),
        ),
        migrations.AlterUniqueTogether(
            name='geocoordinate',
            unique_together=set([('lat', 'lon')]),
        ),
        migrations.AddField(
            model_name='country',
            name='geocoordinate',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.GeoCoordinate'),
        ),
        migrations.AddField(
            model_name='city',
            name='geocoordinate',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.GeoCoordinate'),
        ),
        migrations.AddField(
            model_name='city',
            name='state',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_geo_db.State'),
        ),
        migrations.AlterUniqueTogether(
            name='zipcode',
            unique_together=set([('zipcode', 'geocoordinate')]),
        ),
        migrations.AlterUniqueTogether(
            name='userlocation',
            unique_together=set([('user', 'location')]),
        ),
        migrations.AlterUniqueTogether(
            name='state',
            unique_together=set([('country', 'name')]),
        ),
        migrations.AlterUniqueTogether(
            name='location',
            unique_together=set([('country', 'state', 'city', 'zipcode', 'geocoordinate')]),
        ),
        migrations.AlterUniqueTogether(
            name='city',
            unique_together=set([('state', 'name')]),
        ),
    ]
