# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2017-10-14 05:08
from __future__ import unicode_literals

import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        ('wazimap', '0008_auto_20170424_1209'),
    ]

    operations = [
        migrations.CreateModel(
            name='Dataset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text=b'Friendly name of this dataset.', max_length=100, unique=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='DBTable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text=b'Name of the physical database table containing data for this DB table.', max_length=100, unique=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='FieldTable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.SlugField(help_text=b'Name for this table. No spaces.', max_length=1024, unique=True)),
                ('universe', models.CharField(help_text=b"Universe this table describes, such as 'Population', 'Households', or 'Youth aged 15-24'.", max_length=1024)),
                ('stat_type', models.CharField(choices=[(b'number', b'number'), (b'percentage', b'percentage')], default=b'number', max_length=10)),
                ('description', models.CharField(blank=True, help_text=b'Helpful description of this table (optional). Generated automatically for FieldTables if left blank.', max_length=1024, null=True)),
                ('fields', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=100, unique=True), size=None, help_text=b'Comma-separated ordered list of fields this table describes.')),
                ('denominator_key', models.CharField(blank=True, help_text=b'The key value of the rightmost field that should be used as the "total" column, instead of summing over the values for each row. This is necessary when the table doesn\'t describe a true partitioning of the dataset (ie. the row values sum to more than the total population).  This will be used as the total column once the id of the column has been calculated.', max_length=50, null=True)),
                ('has_total', models.BooleanField(default=True, help_text=b'Does it make sense to calculate a total column and express percentages for values in this table?')),
                ('value_type', models.CharField(choices=[(b'Integer', b'Integer'), (b'Float', b'Float')], default=b'Integer', max_length=20)),
                ('dataset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.Dataset')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='FieldTableRelease',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('data_table', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.FieldTable')),
                ('db_table', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.DBTable')),
            ],
        ),
        migrations.CreateModel(
            name='Release',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text=b'Name of this release, excluding the year.', max_length=100)),
                ('year', models.CharField(help_text=b'Primary year of this release. Will be used for sorting.', max_length=50)),
                ('dataset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='releases', to='wazimap.Dataset')),
            ],
            options={
                'ordering': ['name', 'year'],
            },
        ),
        migrations.CreateModel(
            name='SimpleTable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.SlugField(help_text=b'Name for this table. No spaces.', max_length=1024, unique=True)),
                ('universe', models.CharField(help_text=b"Universe this table describes, such as 'Population', 'Households', or 'Youth aged 15-24'.", max_length=1024)),
                ('stat_type', models.CharField(choices=[(b'number', b'number'), (b'percentage', b'percentage')], default=b'number', max_length=10)),
                ('description', models.CharField(blank=True, help_text=b'Helpful description of this table (optional). Generated automatically for FieldTables if left blank.', max_length=1024, null=True)),
                ('total_column', models.CharField(help_text=b"Name of the column that contains the total value of all the columns in the row. Wazimap usse this to express column values as a percentage. If this is not set, the table doesn't have the concept of a total and only absolute values (not percentages) will be displayed.", max_length=50, null=True)),
                ('dataset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.Dataset')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='SimpleTableRelease',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('data_table', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.SimpleTable')),
                ('db_table', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.DBTable')),
                ('release', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.Release')),
            ],
        ),
        migrations.AddField(
            model_name='simpletable',
            name='db_table_releases',
            field=models.ManyToManyField(through='wazimap.SimpleTableRelease', to='wazimap.DBTable'),
        ),
        migrations.AddField(
            model_name='fieldtablerelease',
            name='release',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wazimap.Release'),
        ),
        migrations.AddField(
            model_name='fieldtable',
            name='db_table_releases',
            field=models.ManyToManyField(through='wazimap.FieldTableRelease', to='wazimap.DBTable'),
        ),
        migrations.AlterUniqueTogether(
            name='release',
            unique_together=set([('year', 'dataset')]),
        ),
    ]
