# Generated by Django 2.0.5 on 2018-05-15 11:38

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name="Subscription",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="created at"
                    ),
                ),
                ("title", models.CharField(max_length=200, verbose_name="title")),
                ("starts_at", models.DateField(verbose_name="starts at")),
                (
                    "ends_at",
                    models.DateField(blank=True, null=True, verbose_name="ends at"),
                ),
                (
                    "periodicity",
                    models.CharField(
                        choices=[("monthly", "monthly"), ("weekly", "weekly")],
                        max_length=20,
                        verbose_name="periodicity",
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2, max_digits=10, verbose_name="amount"
                    ),
                ),
                ("is_active", models.BooleanField(verbose_name="is active")),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="user",
                    ),
                ),
            ],
            options={
                "verbose_name": "subscription", "verbose_name_plural": "subscriptions"
            },
        ),
        migrations.CreateModel(
            name="SubscriptionPeriod",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("starts_at", models.DateField(verbose_name="starts at")),
                ("ends_at", models.DateField(verbose_name="ends at")),
                (
                    "subscription",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="periods",
                        to="user_subscriptions.Subscription",
                        verbose_name="subscription",
                    ),
                ),
            ],
            options={
                "verbose_name": "subscription period",
                "verbose_name_plural": "subscription periods",
            },
        ),
        migrations.AlterUniqueTogether(
            name="subscriptionperiod", unique_together={("subscription", "starts_at")}
        ),
    ]
