# Generated by Django 2.1.5 on 2019-02-06 19:45

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django_extensions.db.fields
import planout_experiments.models
import simple_history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Experiment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(max_length=140)),
                ('salt', models.CharField(blank=True, help_text="Used to hash users into different buckets, change this if you want to 'shuffle' which users see certain variations", max_length=140)),
                ('planout_json', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=planout_experiments.models.default_planout, help_text='JSON experiment description using the planout design language, user the editor at http://planout-editor.herokuapp.com/', null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ExperimentLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('data', django.contrib.postgres.fields.jsonb.JSONField()),
                ('experiment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='experiment_logs', to='planout_experiments.Experiment')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ExperimentResult',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('total_exposures', models.PositiveIntegerField(default=0)),
                ('total_goal_achievements', models.PositiveIntegerField(default=0)),
                ('success_value', models.FloatField(default=0)),
                ('success_rate', models.FloatField(default=0)),
                ('experiment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='planout_experiments.Experiment')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Exposure',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('event_user_identifier', models.CharField(blank=True, help_text='When a user is not available user identifier/identifier_type to identifier enrollee', max_length=140, null=True)),
                ('event_user_identifier_type', models.CharField(blank=True, help_text='When a user is not available user identifier/identifier_type to identifier enrollee', max_length=140, null=True)),
                ('uuid', models.UUIDField(blank=True, editable=False, null=True, unique=True)),
                ('seen_at', models.DateTimeField(blank=True, db_index=True, default=planout_experiments.models.default_now, editable=False, help_text='defaults to created unless overridden', null=True)),
                ('data_source', models.CharField(blank=True, help_text='What system/code path this data came from', max_length=140, null=True)),
                ('data_meta', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, null=True)),
                ('app_version', models.CharField(blank=True, help_text='The app version that sent this impression', max_length=32, null=True)),
                ('event_user', models.ForeignKey(blank=True, help_text='user performing event all events should have either a user or event_user_identifier/event_user_identifier_type', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='planout_experiments_exposure_related', to=settings.AUTH_USER_MODEL)),
                ('experiment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exposures', to='planout_experiments.Experiment')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Goal',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(max_length=140)),
                ('description', models.TextField()),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='GoalAchievement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('event_user_identifier', models.CharField(blank=True, help_text='When a user is not available user identifier/identifier_type to identifier enrollee', max_length=140, null=True)),
                ('event_user_identifier_type', models.CharField(blank=True, help_text='When a user is not available user identifier/identifier_type to identifier enrollee', max_length=140, null=True)),
                ('uuid', models.UUIDField(blank=True, editable=False, null=True, unique=True)),
                ('seen_at', models.DateTimeField(blank=True, db_index=True, default=planout_experiments.models.default_now, editable=False, help_text='defaults to created unless overridden', null=True)),
                ('data_source', models.CharField(blank=True, help_text='What system/code path this data came from', max_length=140, null=True)),
                ('data_meta', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, null=True)),
                ('app_version', models.CharField(blank=True, help_text='The app version that sent this impression', max_length=32, null=True)),
                ('value', models.FloatField(default=1.0, help_text="If the value isn't just binary it can be stored as a float here, positive values should be positive, 1.0 is assumed to be a 'true' positive goal achievement")),
                ('object_id', models.PositiveIntegerField(blank=True, null=True)),
                ('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
                ('event_user', models.ForeignKey(blank=True, help_text='user performing event all events should have either a user or event_user_identifier/event_user_identifier_type', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='planout_experiments_goalachievement_related', to=settings.AUTH_USER_MODEL)),
                ('goal', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='achivements', to='planout_experiments.Goal')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='HistoricalExperiment',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(max_length=140)),
                ('salt', models.CharField(blank=True, help_text="Used to hash users into different buckets, change this if you want to 'shuffle' which users see certain variations", max_length=140)),
                ('planout_json', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=planout_experiments.models.default_planout, help_text='JSON experiment description using the planout design language, user the editor at http://planout-editor.herokuapp.com/', null=True)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical experiment',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalExperimentResult',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('total_exposures', models.PositiveIntegerField(default=0)),
                ('total_goal_achievements', models.PositiveIntegerField(default=0)),
                ('success_value', models.FloatField(default=0)),
                ('success_rate', models.FloatField(default=0)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('experiment', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='planout_experiments.Experiment')),
                ('goal', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='planout_experiments.Goal')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical experiment result',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalGoal',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(max_length=140)),
                ('description', models.TextField()),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical goal',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalVariation',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('key', models.CharField(max_length=140)),
                ('value', models.TextField()),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('experiment', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='planout_experiments.Experiment')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical variation',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Variation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('key', models.CharField(max_length=140)),
                ('value', models.TextField()),
                ('experiment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='variations', to='planout_experiments.Experiment')),
            ],
        ),
        migrations.AddField(
            model_name='historicalexperimentresult',
            name='variation',
            field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='planout_experiments.Variation'),
        ),
        migrations.AddField(
            model_name='exposure',
            name='variation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exposures', to='planout_experiments.Variation'),
        ),
        migrations.AddField(
            model_name='experimentresult',
            name='goal',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='planout_experiments.Goal'),
        ),
        migrations.AddField(
            model_name='experimentresult',
            name='variation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='planout_experiments.Variation'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='goals',
            field=models.ManyToManyField(blank=True, to='planout_experiments.Goal'),
        ),
        migrations.AlterUniqueTogether(
            name='variation',
            unique_together={('experiment', 'key', 'value')},
        ),
    ]
