# Generated by Django 2.2.24 on 2021-11-10 22:49

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import simple_history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('organizations', '0005_historicalorganization_historicalteam'),
        ('organizations', '0001_squashed'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Plan',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('pub_date', models.DateTimeField(auto_now_add=True, verbose_name='Publication date')),
                ('modified_date', models.DateTimeField(auto_now=True, verbose_name='Modified date')),
                ('name', models.CharField(max_length=100, verbose_name='Name')),
                ('description', models.CharField(blank=True, max_length=255, null=True, verbose_name='Description')),
                ('slug', models.SlugField(max_length=255, unique=True, verbose_name='Slug')),
                ('stripe_id', models.CharField(max_length=100, verbose_name='Stripe ID')),
                ('price', models.IntegerField(verbose_name='Price')),
                ('trial', models.IntegerField(verbose_name='Trial')),
                ('published', models.BooleanField(default=False, help_text="<b>Warning</b>: This will make this subscription available for users to buy. Don't add unless you're sure.", verbose_name='Published')),
                ('for_organizations', models.ManyToManyField(blank=True, db_table='organizations_plan_for_organizations', related_name='available_plans', to='organizations.Organization', verbose_name='For organizations')),
            ],
            options={
                'db_table': 'organizations_plan',
                'ordering': ('price',),
            },
        ),
        migrations.CreateModel(
            name='HistoricalSubscription',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('extra_history_user_id', models.IntegerField(blank=True, db_index=True, null=True, verbose_name='ID')),
                ('extra_history_user_username', models.CharField(db_index=True, max_length=150, null=True, verbose_name='username')),
                ('locked', models.BooleanField(default=False, help_text='Locked plan for custom contracts', verbose_name='Locked plan')),
                ('modified_date', models.DateTimeField(blank=True, editable=False, verbose_name='Modified date')),
                ('stripe_id', models.CharField(blank=True, max_length=100, null=True, verbose_name='Stripe subscription ID')),
                ('status', models.CharField(max_length=16, verbose_name='Subscription status')),
                ('start_date', models.DateTimeField(blank=True, null=True, verbose_name='Start date')),
                ('end_date', models.DateTimeField(blank=True, null=True, verbose_name='End date')),
                ('trial_end_date', models.DateTimeField(blank=True, null=True, verbose_name='Trial end date')),
                ('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)),
                ('organization', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='organizations.Organization', verbose_name='Organization')),
                ('plan', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='subscriptions.Plan', verbose_name='Plan')),
                ('extra_history_browser', models.CharField(blank=True, max_length=250, null=True, verbose_name='Browser user-agent')),
                ('extra_history_ip', models.CharField(blank=True, max_length=250, null=True, verbose_name='IP address')),
            ],
            options={
                'verbose_name': 'historical subscription',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Subscription',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('locked', models.BooleanField(default=False, help_text='Locked plan for custom contracts', verbose_name='Locked plan')),
                ('modified_date', models.DateTimeField(auto_now=True, verbose_name='Modified date')),
                ('stripe_id', models.CharField(blank=True, max_length=100, null=True, verbose_name='Stripe subscription ID')),
                ('status', models.CharField(max_length=16, verbose_name='Subscription status')),
                ('start_date', models.DateTimeField(blank=True, null=True, verbose_name='Start date')),
                ('end_date', models.DateTimeField(blank=True, null=True, verbose_name='End date')),
                ('trial_end_date', models.DateTimeField(blank=True, null=True, verbose_name='Trial end date')),
                ('organization', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='organizations.Organization', verbose_name='Organization')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='subscriptions.Plan', verbose_name='Plan')),
            ],
            options={
                'db_table': 'organizations_subscription',
            },
        ),
        migrations.CreateModel(
            name='PlanFeature',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('pub_date', models.DateTimeField(auto_now_add=True, verbose_name='Publication date')),
                ('modified_date', models.DateTimeField(auto_now=True, verbose_name='Modified date')),
                ('feature_type', models.CharField(choices=[('cname', 'Custom domain'), ('cdn', 'CDN public documentation'), ('ssl', 'Custom SSL configuration'), ('support', 'Support SLA'), ('private_docs', 'Private documentation'), ('embed_api', 'Embed content via API'), ('search_analytics', 'Search analytics'), ('pageviews_analytics', 'Pageview analytics'), ('concurrent_builds', 'Concurrent builds'), ('sso', 'Single sign on (SSO) with Google'), ('urls', 'Custom URLs'), ('audit-logs', 'Audit logs'), ('audit-pageviews', 'Record every page view')], max_length=32, verbose_name='Type')),
                ('value', models.IntegerField(blank=True, null=True, verbose_name='Numeric value')),
                ('description', models.CharField(blank=True, max_length=255, null=True, verbose_name='Description')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='features', to='subscriptions.Plan')),
            ],
            options={
                'db_table': 'organizations_planfeature',
                'unique_together': {('plan', 'feature_type')},
            },
        ),
    ]
