# Generated by Django 2.1.4 on 2019-02-27 21:37

import django.core.validators
import django.db.models.deletion
from django.db import migrations, models

import djstripe.enums
import djstripe.fields


def postgres_migration_prep(apps, schema_editor):
    """
    Set null text fields to empty string to workaround incompatibility with migration 0003 on postgres
    See https://github.com/dj-stripe/dj-stripe/issues/850
    """

    Account = apps.get_model("djstripe", "Account")
    BankAccount = apps.get_model("djstripe", "BankAccount")
    Card = apps.get_model("djstripe", "Card")
    Charge = apps.get_model("djstripe", "Charge")
    Customer = apps.get_model("djstripe", "Customer")
    Event = apps.get_model("djstripe", "Event")
    Invoice = apps.get_model("djstripe", "Invoice")
    Payout = apps.get_model("djstripe", "Payout")
    Plan = apps.get_model("djstripe", "Plan")
    Product = apps.get_model("djstripe", "Product")
    Refund = apps.get_model("djstripe", "Refund")
    Source = apps.get_model("djstripe", "Source")
    Transfer = apps.get_model("djstripe", "Transfer")

    model_fields = [
        (
            Account,
            (
                "business_name",
                "business_primary_color",
                "business_url",
                "payout_statement_descriptor",
                "product_description",
                "support_url",
            ),
        ),
        (BankAccount, ("account_holder_name",)),
        (
            Card,
            (
                "address_city",
                "address_country",
                "address_line1",
                "address_line1_check",
                "address_line2",
                "address_state",
                "address_zip",
                "address_zip_check",
                "country",
                "cvc_check",
                "dynamic_last4",
                "fingerprint",
                "name",
                "tokenization_method",
            ),
        ),
        (
            Charge,
            (
                "failure_code",
                "failure_message",
                "receipt_email",
                "receipt_number",
                "statement_descriptor",
                "transfer_group",
            ),
        ),
        (Customer, ("business_vat_id", "currency", "email")),
        (Event, ("idempotency_key", "request_id")),
        (
            Invoice,
            ("hosted_invoice_url", "invoice_pdf", "number", "statement_descriptor"),
        ),
        (Payout, ("failure_code", "failure_message", "statement_descriptor")),
        (Plan, ("aggregate_usage", "billing_scheme", "nickname")),
        (Product, ("caption", "statement_descriptor", "unit_label")),
        (Refund, ("failure_reason", "reason", "receipt_number")),
        (Source, ("currency", "statement_descriptor")),
        (Transfer, ("transfer_group",)),
    ]

    for model, fields in model_fields:
        for field in fields:
            filter_param = {"{}__isnull".format(field): True}
            update_param = {field: ""}
            model.objects.filter(**filter_param).update(**update_param)


class Migration(migrations.Migration):
    def __init__(self, *args, **kwargs):
        # Hack to support sqlite for quick testing. Without this migrations fail with:
        #    "django.db.utils.NotSupportedError: Renaming the 'djstripe_paymentmethod' table while in a transaction
        #    is not supported on SQLite because it would break referential integrity.
        #    Try adding `atomic = False` to the Migration class."
        from django.db import connection

        # use getattr because I think connection.vendor isn't documented
        if getattr(connection, "vendor", None) == "sqlite":
            self.atomic = False

        super().__init__(*args, **kwargs)

    dependencies = [("djstripe", "0002_auto_20180627_1121")]

    operations = [
        migrations.RunPython(postgres_migration_prep, migrations.RunPython.noop),
        migrations.AlterField(
            model_name="account",
            name="display_name",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The display name for this account. This is used on the Stripe Dashboard to differentiate between accounts.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="support_email",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A publicly shareable support email address for the business",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="support_phone",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A publicly shareable support phone number for the business",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="customer",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="legacy_cards",
                to="djstripe.Customer",
            ),
        ),
        migrations.AddField(
            model_name="coupon",
            name="name",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Name of the coupon displayed to customers on for instance invoices or receipts.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="source",
            name="type",
            field=djstripe.fields.StripeEnumField(
                enum=djstripe.enums.SourceType,
                help_text="The type of the source.",
                max_length=20,
            ),
        ),
        migrations.AddField(
            model_name="plan",
            name="active",
            field=models.BooleanField(
                default=True,
                help_text="Whether the plan is currently available for new subscriptions.",
            ),
            preserve_default=False,
        ),
        migrations.RemoveField(model_name="charge", name="fraudulent"),
        migrations.RemoveField(model_name="charge", name="receipt_sent"),
        migrations.RemoveField(model_name="charge", name="source_stripe_id"),
        migrations.RemoveField(model_name="charge", name="source_type"),
        migrations.RemoveField(model_name="charge", name="fee"),
        migrations.RemoveField(model_name="charge", name="fee_details"),
        migrations.RemoveField(model_name="transfer", name="date"),
        migrations.RemoveField(model_name="transfer", name="destination_type"),
        migrations.RemoveField(model_name="transfer", name="failure_code"),
        migrations.RemoveField(model_name="transfer", name="failure_message"),
        migrations.RemoveField(model_name="transfer", name="fee"),
        migrations.RemoveField(model_name="transfer", name="fee_details"),
        migrations.RemoveField(model_name="transfer", name="statement_descriptor"),
        migrations.RemoveField(model_name="transfer", name="status"),
        migrations.AlterModelOptions(
            name="account", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="bankaccount", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(name="card", options={"get_latest_by": "created"}),
        migrations.AlterModelOptions(
            name="charge", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="dispute", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="event", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="fileupload", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="invoiceitem", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="payout", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="product", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="refund", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="source", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="subscription", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="transfer", options={"get_latest_by": "created"}
        ),
        migrations.AlterModelOptions(
            name="upcominginvoice", options={"get_latest_by": "created"}
        ),
        migrations.CreateModel(
            name="CountrySpec",
            fields=[
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "id",
                    models.CharField(max_length=2, primary_key=True, serialize=False),
                ),
                (
                    "default_currency",
                    djstripe.fields.StripeCurrencyCodeField(
                        help_text="The default currency for this country. This applies to both payment methods and bank accounts.",
                        max_length=3,
                    ),
                ),
                (
                    "supported_bank_account_currencies",
                    djstripe.fields.JSONField(
                        help_text="Currencies that can be accepted in the specific country (for transfers)."
                    ),
                ),
                (
                    "supported_payment_currencies",
                    djstripe.fields.JSONField(
                        help_text="Currencies that can be accepted in the specified country (for payments)."
                    ),
                ),
                (
                    "supported_payment_methods",
                    djstripe.fields.JSONField(
                        help_text="Payment methods available in the specified country."
                    ),
                ),
                (
                    "supported_transfer_countries",
                    djstripe.fields.JSONField(
                        help_text="Countries that can accept transfers from the specified country."
                    ),
                ),
                (
                    "verification_fields",
                    djstripe.fields.JSONField(
                        help_text="Lists the types of verification data needed to keep an account open."
                    ),
                ),
            ],
            options={"abstract": False},
        ),
        migrations.CreateModel(
            name="BalanceTransaction",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "amount",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Gross amount of the transaction, in cents."
                    ),
                ),
                (
                    "available_on",
                    djstripe.fields.StripeDateTimeField(
                        help_text="The date the transaction's net funds will become available in the Stripe balance."
                    ),
                ),
                (
                    "currency",
                    djstripe.fields.StripeCurrencyCodeField(
                        help_text="Three-letter ISO currency code", max_length=3
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(null=True, decimal_places=6, max_digits=8),
                ),
                (
                    "fee",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Fee (in cents) paid for this transaction."
                    ),
                ),
                ("fee_details", djstripe.fields.JSONField()),
                (
                    "net",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Net amount of the transaction, in cents."
                    ),
                ),
                (
                    "status",
                    djstripe.fields.StripeEnumField(
                        enum=djstripe.enums.BalanceTransactionStatus, max_length=9
                    ),
                ),
                (
                    "type",
                    djstripe.fields.StripeEnumField(
                        enum=djstripe.enums.BalanceTransactionType, max_length=22
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="ScheduledQueryRun",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "data_load_time",
                    djstripe.fields.StripeDateTimeField(
                        help_text="When the query was run, Sigma contained a snapshot of your Stripe data at this time."
                    ),
                ),
                (
                    "error",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="If the query run was not succeesful, contains information about the failure.",
                        null=True,
                    ),
                ),
                (
                    "result_available_until",
                    djstripe.fields.StripeDateTimeField(
                        help_text="Time at which the result expires and is no longer available for download."
                    ),
                ),
                (
                    "sql",
                    models.TextField(help_text="SQL for the query.", max_length=5000),
                ),
                (
                    "status",
                    djstripe.fields.StripeEnumField(
                        enum=djstripe.enums.ScheduledQueryRunStatus,
                        help_text="The query's execution status.",
                        max_length=9,
                    ),
                ),
                (
                    "title",
                    models.TextField(help_text="Title of the query.", max_length=5000),
                ),
                (
                    "file",
                    models.ForeignKey(
                        blank=True,
                        help_text="The file object representing the results of the query.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="djstripe.FileUpload",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="SubscriptionItem",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "quantity",
                    models.PositiveIntegerField(
                        help_text="The quantity of the plan to which the customer should be subscribed."
                    ),
                ),
                (
                    "plan",
                    models.ForeignKey(
                        help_text="The plan the customer is subscribed to.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subscription_items",
                        to="djstripe.Plan",
                    ),
                ),
                (
                    "subscription",
                    models.ForeignKey(
                        help_text="The subscription this subscription item belongs to.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="djstripe.Subscription",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="TransferReversal",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "amount",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Amount, in cents."
                    ),
                ),
                (
                    "currency",
                    djstripe.fields.StripeCurrencyCodeField(
                        help_text="Three-letter ISO currency code", max_length=3
                    ),
                ),
                (
                    "balance_transaction",
                    models.ForeignKey(
                        blank=True,
                        help_text="Balance transaction that describes the impact on your account balance.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="transfer_reversals",
                        to="djstripe.BalanceTransaction",
                    ),
                ),
                (
                    "transfer",
                    models.ForeignKey(
                        help_text="The transfer that was reversed.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="reversals",
                        to="djstripe.Transfer",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="UsageRecord",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "quantity",
                    models.PositiveIntegerField(
                        help_text="The quantity of the plan to which the customer should be subscribed."
                    ),
                ),
                (
                    "subscription_item",
                    models.ForeignKey(
                        help_text="The subscription item this usage record contains data for.",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="usage_records",
                        to="djstripe.SubscriptionItem",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="ApplicationFee",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="A description of this object.", null=True
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "amount",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Amount earned, in cents."
                    ),
                ),
                (
                    "amount_refunded",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Amount in cents refunded (can be less than the amount attribute on the fee if a partial refund was issued)"
                    ),
                ),
                (
                    "currency",
                    djstripe.fields.StripeCurrencyCodeField(
                        help_text="Three-letter ISO currency code", max_length=3
                    ),
                ),
                (
                    "refunded",
                    models.BooleanField(
                        help_text="Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false."
                    ),
                ),
                (
                    "balance_transaction",
                    models.ForeignKey(
                        help_text="Balance transaction that describes the impact on your account balance.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="djstripe.BalanceTransaction",
                    ),
                ),
                (
                    "charge",
                    models.ForeignKey(
                        help_text="The charge that the application fee was taken from.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="djstripe.Charge",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.CreateModel(
            name="ApplicationFeeRefund",
            fields=[
                (
                    "djstripe_id",
                    models.BigAutoField(
                        primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("id", djstripe.fields.StripeIdField(max_length=255, unique=True)),
                (
                    "livemode",
                    models.NullBooleanField(
                        default=None,
                        help_text="Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.",
                    ),
                ),
                (
                    "created",
                    djstripe.fields.StripeDateTimeField(
                        blank=True,
                        help_text="The datetime this object was created in stripe.",
                        null=True,
                    ),
                ),
                (
                    "metadata",
                    djstripe.fields.JSONField(
                        blank=True,
                        help_text="A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.",
                        null=True,
                    ),
                ),
                ("djstripe_created", models.DateTimeField(auto_now_add=True)),
                ("djstripe_updated", models.DateTimeField(auto_now=True)),
                (
                    "amount",
                    djstripe.fields.StripeQuantumCurrencyAmountField(
                        help_text="Amount refunded, in cents."
                    ),
                ),
                (
                    "currency",
                    djstripe.fields.StripeCurrencyCodeField(
                        help_text="Three-letter ISO currency code", max_length=3
                    ),
                ),
                (
                    "balance_transaction",
                    models.ForeignKey(
                        help_text="Balance transaction that describes the impact on your account balance.",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="djstripe.BalanceTransaction",
                    ),
                ),
                (
                    "fee",
                    models.ForeignKey(
                        help_text="The application fee that was refunded",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="refunds",
                        to="djstripe.ApplicationFee",
                    ),
                ),
            ],
            options={"get_latest_by": "created", "abstract": False},
        ),
        migrations.AddField(
            model_name="charge",
            name="balance_transaction",
            field=models.ForeignKey(
                help_text="The balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
            ),
        ),
        migrations.AddField(
            model_name="payout",
            name="balance_transaction",
            field=models.ForeignKey(
                help_text="Balance transaction that describes the impact on your account balance.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
            ),
        ),
        migrations.AddField(
            model_name="payout",
            name="failure_balance_transaction",
            field=models.ForeignKey(
                help_text="If the payout failed or was canceled, this will be the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
                related_name="failure_payouts",
            ),
        ),
        migrations.AddField(
            model_name="refund",
            name="balance_transaction",
            field=models.ForeignKey(
                help_text="Balance transaction that describes the impact on your account balance.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
            ),
        ),
        migrations.AddField(
            model_name="refund",
            name="failure_balance_transaction",
            field=models.ForeignKey(
                help_text="If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.",
                null=True,
                blank=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
                related_name="failure_refunds",
            ),
        ),
        migrations.AddField(
            model_name="transfer",
            name="balance_transaction",
            field=models.ForeignKey(
                blank=True,
                help_text="Balance transaction that describes the impact on your account balance.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="djstripe.BalanceTransaction",
            ),
        ),
        migrations.RenameField(
            model_name="account", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="bankaccount", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(model_name="card", old_name="stripe_id", new_name="id"),
        migrations.RenameField(
            model_name="charge", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="customer", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="dispute", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(model_name="event", old_name="stripe_id", new_name="id"),
        migrations.RenameField(
            model_name="fileupload", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="invoice", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="invoiceitem", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="payout", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(model_name="plan", old_name="stripe_id", new_name="id"),
        migrations.RenameField(
            model_name="product", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="refund", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="source", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="subscription", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="transfer", old_name="stripe_id", new_name="id"
        ),
        migrations.RenameField(
            model_name="coupon", old_name="stripe_id", new_name="id"
        ),
        migrations.AlterField(
            model_name="coupon",
            name="percent_off",
            field=djstripe.fields.StripePercentField(
                blank=True,
                decimal_places=2,
                help_text="Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a $100 invoice $50 instead.",
                max_digits=5,
                null=True,
                validators=[
                    django.core.validators.MinValueValidator(1),
                    django.core.validators.MaxValueValidator(100),
                ],
            ),
        ),
        # Update all text-type fields to non-null CharField blank=True default=""
        migrations.AlterField(
            model_name="account",
            name="business_name",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The publicly visible name of the business",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="business_primary_color",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A CSS hex color value representing the primary branding color for this account",
                max_length=7,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="business_url",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The publicly visible website of the business",
                max_length=200,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="payout_statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The text that appears on the bank account statement for payouts.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="product_description",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Internal-only description of the product sold or service provided by the business. It’s used by Stripe for risk and underwriting purposes.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="account",
            name="support_url",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A publicly shareable URL that provides support for this account",
                max_length=200,
            ),
        ),
        migrations.AlterField(
            model_name="bankaccount",
            name="account_holder_name",
            field=models.TextField(
                blank=True,
                default="",
                help_text="The name of the person or business that owns the bank account.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_city",
            field=models.TextField(
                blank=True,
                default="",
                help_text="City/District/Suburb/Town/Village.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_country",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Billing address country.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_line1",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Street address/PO Box/Company name.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_line1_check",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.CardCheckResult,
                help_text="If `address_line1` was provided, results of the check.",
                max_length=11,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_line2",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Apartment/Suite/Unit/Building.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_state",
            field=models.TextField(
                blank=True,
                default="",
                help_text="State/County/Province/Region.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_zip",
            field=models.TextField(
                blank=True, default="", help_text="ZIP or postal code.", max_length=5000
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="address_zip_check",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.CardCheckResult,
                help_text="If `address_zip` was provided, results of the check.",
                max_length=11,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="country",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Two-letter ISO code representing the country of the card.",
                max_length=2,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="cvc_check",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.CardCheckResult,
                help_text="If a CVC was provided, results of the check.",
                max_length=11,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="dynamic_last4",
            field=models.CharField(
                blank=True,
                default="",
                help_text="(For tokenized numbers only.) The last four digits of the device account number.",
                max_length=4,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="fingerprint",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Uniquely identifies this particular card number.",
                max_length=16,
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="name",
            field=models.TextField(
                blank=True, default="", help_text="Cardholder name.", max_length=5000
            ),
        ),
        migrations.AlterField(
            model_name="card",
            name="tokenization_method",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.CardTokenizationMethod,
                help_text="If the card number is tokenized, this is the method that was used.",
                max_length=11,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="failure_code",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.ApiErrorCode,
                help_text="Error code explaining reason for charge failure if available.",
                max_length=42,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="failure_message",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Message to user further explaining reason for charge failure if available.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="receipt_email",
            field=models.TextField(
                blank=True,
                default="",
                help_text="The email address that the receipt for this charge was sent to.",
                max_length=800,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="receipt_number",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The transaction number that appears on email receipts sent for this charge.",
                max_length=14,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="An arbitrary string to be displayed on your customer's credit card statement. The statement description may not include <>\"' characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.",
                max_length=22,
            ),
        ),
        migrations.AlterField(
            model_name="charge",
            name="transfer_group",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A string that identifies this transaction as part of a group.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="customer",
            name="business_vat_id",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The customer's VAT identification number.",
                max_length=20,
            ),
        ),
        migrations.AlterField(
            model_name="customer",
            name="currency",
            field=djstripe.fields.StripeCurrencyCodeField(
                default="",
                help_text="The currency the customer can be charged in for recurring billing purposes",
                max_length=3,
            ),
        ),
        migrations.AlterField(
            model_name="customer",
            name="email",
            field=models.TextField(blank=True, default="", max_length=5000),
        ),
        migrations.AlterField(
            model_name="event",
            name="idempotency_key",
            field=models.TextField(blank=True, default=""),
        ),
        migrations.AlterField(
            model_name="event",
            name="request_id",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Information about the request that triggered this event, for traceability purposes. If empty string then this is an old entry without that data. If Null then this is not an old entry, but a Stripe 'automated' event with no associated request.",
                max_length=50,
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="hosted_invoice_url",
            field=models.TextField(
                blank=True,
                default="",
                help_text="The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been frozen yet, this will be null.",
                max_length=799,
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="invoice_pdf",
            field=models.TextField(
                blank=True,
                default="",
                help_text="The link to download the PDF for the invoice. If the invoice has not been frozen yet, this will be null.",
                max_length=799,
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="number",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer’s unique invoice_prefix if it is specified.",
                max_length=64,
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="An arbitrary string to be displayed on your customer's credit card statement. The statement description may not include <>\"' characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.",
                max_length=22,
            ),
        ),
        migrations.AlterField(
            model_name="payout",
            name="failure_code",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.PayoutFailureCode,
                help_text="Error code explaining reason for transfer failure if available. See https://stripe.com/docs/api/python#transfer_failures.",
                max_length=23,
            ),
        ),
        migrations.AlterField(
            model_name="payout",
            name="failure_message",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Message to user further explaining reason for payout failure if available.",
            ),
        ),
        migrations.AlterField(
            model_name="payout",
            name="statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Extra information about a payout to be displayed on the user's bank statement.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="plan",
            name="aggregate_usage",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.PlanAggregateUsage,
                help_text="Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are `sum` for summing up all usage during a period, `last_during_period` for picking the last usage record reported within a period, `last_ever` for picking the last usage record ever (across period bounds) or max which picks the usage record with the maximum reported usage during a period. Defaults to `sum`.",
                max_length=18,
            ),
        ),
        migrations.AlterField(
            model_name="plan",
            name="billing_scheme",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.PlanBillingScheme,
                help_text="Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with `usage_type=licensed`), or per unit of total usage (for plans with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes.",
                max_length=8,
            ),
        ),
        migrations.AlterField(
            model_name="plan",
            name="nickname",
            field=models.TextField(
                blank=True,
                default="",
                help_text="A brief description of the plan, hidden from customers.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="product",
            name="caption",
            field=models.TextField(
                blank=True,
                default="",
                help_text="A short one-line description of the product, meant to be displayableto the customer. Only applicable to products of `type=good`.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="product",
            name="statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only available on products of type=`service`.",
                max_length=22,
            ),
        ),
        migrations.AlterField(
            model_name="product",
            name="unit_label",
            field=models.CharField(blank=True, default="", max_length=12),
        ),
        migrations.AlterField(
            model_name="refund",
            name="failure_reason",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.RefundFailureReason,
                help_text="If the refund failed, the reason for refund failure if known.",
                max_length=24,
            ),
        ),
        migrations.AlterField(
            model_name="refund",
            name="reason",
            field=djstripe.fields.StripeEnumField(
                blank=True,
                default="",
                enum=djstripe.enums.RefundReason,
                help_text="Reason for the refund.",
                max_length=21,
            ),
        ),
        migrations.AlterField(
            model_name="refund",
            name="receipt_number",
            field=models.CharField(
                blank=True,
                default="",
                help_text="The transaction number that appears on email receipts sent for this charge.",
                max_length=9,
            ),
        ),
        migrations.AlterField(
            model_name="source",
            name="currency",
            field=djstripe.fields.StripeCurrencyCodeField(
                blank=True,
                default="",
                help_text="Three-letter ISO currency code",
                max_length=3,
            ),
        ),
        migrations.AlterField(
            model_name="source",
            name="statement_descriptor",
            field=models.CharField(
                blank=True,
                default="",
                help_text="Extra information about a source. This will appear on your customer's statement every time you charge the source.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="transfer",
            name="transfer_group",
            field=models.CharField(
                blank=True,
                default="",
                help_text="A string that identifies this transaction as part of a group.",
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="product",
            name="name",
            field=models.TextField(
                help_text="The product's name, meant to be displayable to the customer. Applicable to both `service` and `good` types.",
                max_length=5000,
            ),
        ),
        migrations.AlterField(
            model_name="subscription",
            name="plan",
            field=models.ForeignKey(
                blank=True,
                help_text="The plan associated with this subscription. This value will be `null` for multi-plan subscriptions",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="subscriptions",
                to="djstripe.Plan",
            ),
        ),
        migrations.AlterField(
            model_name="subscription",
            name="quantity",
            field=models.IntegerField(
                blank=True,
                help_text="The quantity applied to this subscription. This value will be `null` for multi-plan subscriptions",
                null=True,
            ),
        ),
        migrations.AlterField(
            model_name="plan",
            name="amount",
            field=djstripe.fields.StripeDecimalCurrencyAmountField(
                blank=True,
                decimal_places=2,
                help_text="Amount (as decimal) to be charged on the interval specified.",
                max_digits=8,
                null=True,
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="closed",
            field=models.NullBooleanField(
                default=False,
                help_text="Whether or not the invoice is still trying to collect payment. An invoice is closed if it's either paid or it has been marked closed. A closed invoice will no longer attempt to collect payment.",
            ),
        ),
        migrations.AlterField(
            model_name="invoice",
            name="forgiven",
            field=models.NullBooleanField(
                default=False,
                help_text="Whether or not the invoice has been forgiven. Forgiving an invoice instructs us to update the subscription status as if the invoice were successfully paid. Once an invoice has been forgiven, it cannot be unforgiven or reopened.",
            ),
        ),
        migrations.RenameModel(
            old_name="PaymentMethod", new_name="DjstripePaymentMethod"
        ),
    ]
