# Generated by Django 2.0.7 on 2018-09-24 14:18

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 simple_history.models


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Action',
            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')),
                ('action_method', models.CharField(max_length=140)),
                ('action_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text='kwargs to pass action method')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='BusinessRuleSet',
            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')),
                ('enabled', models.BooleanField(default=False, help_text='Should this rule set execute?')),
                ('name', models.CharField(help_text='A descriptive name so we know what this ruleset does', max_length=140)),
                ('notes', models.TextField(blank=True, null=True)),
                ('signal', models.CharField(help_text='import path of a signal that shoudl fire this ruleset', max_length=240)),
                ('signal_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text="kwargs to pass to signal registration ({'sender': 'Model' would be a common pattern here})")),
                ('stop_on_first_trigger', models.BooleanField(default=False, help_text='Should this ruleset stop on the first triggered block?')),
                ('variables_class', models.CharField(help_text='Import path and class for Variables', max_length=140)),
                ('actions_class', models.CharField(help_text='Import path and class for Actions', max_length=140)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Condition',
            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')),
                ('property_method', models.CharField(max_length=140)),
                ('property_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text='kwargs to pass to the method that gets the left hand side of our comparison')),
                ('comparison_operator', models.CharField(max_length=140)),
                ('value', models.TextField()),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ConditionSet',
            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(help_text='A descriptive name for this group of conditions', max_length=140)),
                ('combination_rule', models.CharField(choices=[('any', 'any'), ('all', 'all')], max_length=10)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='HistoricalAction',
            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')),
                ('action_method', models.CharField(max_length=140)),
                ('action_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text='kwargs to pass action method')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_date', models.DateTimeField()),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
            ],
            options={
                'verbose_name': 'historical action',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalBusinessRuleSet',
            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')),
                ('enabled', models.BooleanField(default=False, help_text='Should this rule set execute?')),
                ('name', models.CharField(help_text='A descriptive name so we know what this ruleset does', max_length=140)),
                ('notes', models.TextField(blank=True, null=True)),
                ('signal', models.CharField(help_text='import path of a signal that shoudl fire this ruleset', max_length=240)),
                ('signal_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text="kwargs to pass to signal registration ({'sender': 'Model' would be a common pattern here})")),
                ('stop_on_first_trigger', models.BooleanField(default=False, help_text='Should this ruleset stop on the first triggered block?')),
                ('variables_class', models.CharField(help_text='Import path and class for Variables', max_length=140)),
                ('actions_class', models.CharField(help_text='Import path and class for Actions', max_length=140)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_date', models.DateTimeField()),
                ('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 business rule set',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalCondition',
            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')),
                ('property_method', models.CharField(max_length=140)),
                ('property_kwargs', django.contrib.postgres.fields.jsonb.JSONField(default={}, help_text='kwargs to pass to the method that gets the left hand side of our comparison')),
                ('comparison_operator', models.CharField(max_length=140)),
                ('value', models.TextField()),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_date', models.DateTimeField()),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('group', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='dynamic_business_rules.ConditionSet')),
                ('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 condition',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalConditionSet',
            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(help_text='A descriptive name for this group of conditions', max_length=140)),
                ('combination_rule', models.CharField(choices=[('any', 'any'), ('all', 'all')], max_length=10)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_date', models.DateTimeField()),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
            ],
            options={
                'verbose_name': 'historical condition set',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='HistoricalRuleBlock',
            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(help_text='Description of what this block does', max_length=140)),
                ('enabled', models.BooleanField(default=False, help_text='Should this block be executed as a part of the rule set?')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_date', models.DateTimeField()),
                ('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)),
                ('rule_set', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='dynamic_business_rules.BusinessRuleSet')),
            ],
            options={
                'verbose_name': 'historical rule block',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='RuleBlock',
            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(help_text='Description of what this block does', max_length=140)),
                ('enabled', models.BooleanField(default=False, help_text='Should this block be executed as a part of the rule set?')),
                ('rule_set', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dynamic_business_rules.BusinessRuleSet')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='historicalconditionset',
            name='block',
            field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='dynamic_business_rules.RuleBlock'),
        ),
        migrations.AddField(
            model_name='historicalconditionset',
            name='history_user',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='historicalconditionset',
            name='parent_condition',
            field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='dynamic_business_rules.ConditionSet'),
        ),
        migrations.AddField(
            model_name='historicalaction',
            name='block',
            field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='dynamic_business_rules.RuleBlock'),
        ),
        migrations.AddField(
            model_name='historicalaction',
            name='history_user',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='conditionset',
            name='block',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='condition_sets', to='dynamic_business_rules.RuleBlock'),
        ),
        migrations.AddField(
            model_name='conditionset',
            name='parent_condition',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='child_condition_sets', to='dynamic_business_rules.ConditionSet'),
        ),
        migrations.AddField(
            model_name='condition',
            name='group',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comditions', to='dynamic_business_rules.ConditionSet'),
        ),
        migrations.AddField(
            model_name='action',
            name='block',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='actions', to='dynamic_business_rules.RuleBlock'),
        ),
    ]
