# Generated by Django 4.2.3 on 2024-01-23 20:58
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models

import django_paddle_billing.encoders
from django_paddle_billing import settings as app_settings


class Migration(migrations.Migration):
    initial = True

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

    operations = [
        migrations.CreateModel(
            name="Address",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                ("country_code", models.CharField(max_length=2)),
            ],
        ),
        migrations.CreateModel(
            name="Business",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Customer",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                ("name", models.CharField(blank=True, max_length=255, null=True)),
                ("email", models.EmailField(max_length=254)),
                (
                    "user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="customers",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Product",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                (
                    "status",
                    models.CharField(
                        choices=[("active", "Active"), ("archived", "Archived")],
                        max_length=10,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Subscription",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("active", "Active"),
                            ("trialing", "Trialing"),
                            ("paused", "Paused"),
                            ("deleted", "Deleted"),
                        ],
                        max_length=10,
                    ),
                ),
                (
                    "account",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="subscriptions",
                        to=app_settings.PADDLE_ACCOUNT_MODEL,
                    ),
                ),
                (
                    "address",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subscriptions",
                        to="django_paddle_billing.address",
                    ),
                ),
                (
                    "business",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subscriptions",
                        to="django_paddle_billing.business",
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subscriptions",
                        to="django_paddle_billing.customer",
                    ),
                ),
                (
                    "products",
                    models.ManyToManyField(related_name="subscriptions", to="django_paddle_billing.product"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Transaction",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="transactions",
                        to="django_paddle_billing.customer",
                    ),
                ),
                (
                    "subscription",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="transactions",
                        to="django_paddle_billing.subscription",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Price",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("occurred_at", models.DateTimeField(blank=True, null=True)),
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                (
                    "data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "custom_data",
                    models.JSONField(
                        blank=True,
                        encoder=django_paddle_billing.encoders.PrettyJSONEncoder,
                        null=True,
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="prices",
                        to="django_paddle_billing.product",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="business",
            name="customer",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="businesses",
                to="django_paddle_billing.customer",
            ),
        ),
        migrations.AddField(
            model_name="address",
            name="customer",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="addresses",
                to="django_paddle_billing.customer",
            ),
        ),
    ]
