from django.db import migrations, models


class Migration(migrations.Migration):
    """
    Give a tenant invoice a way to be paid.

    Today tenant_invoice_send emails a client an invoice with nothing to click.
    These three fields are what a payable link needs: a token that identifies
    the invoice without exposing its id, the Stripe session so a return trip
    can be verified rather than trusted, and a record of which reminders have
    already gone out so a client is never emailed the same notice twice.

    Additive. Every column is blank by default and no existing row changes.

    Deploy this on its own and run migrate before any code that reads these
    columns reaches the server. Shipping a model and its migration together is
    what took every page down on 21 August 2026: Django puts every field in the
    SELECT, so one missing column breaks every query against the table.
    """

    dependencies = [
        ('tenants', '0020_align_help_text'),
    ]

    operations = [
        migrations.AddField(
            model_name='tenantinvoice',
            name='pay_token',
            field=models.CharField(
                blank=True, db_index=True, max_length=64,
                help_text='Random token for the public payment link. Blank means the invoice has no link yet.',
            ),
        ),
        migrations.AddField(
            model_name='tenantinvoice',
            name='stripe_session_id',
            field=models.CharField(
                blank=True, max_length=120,
                help_text='Checkout session, so a return from Stripe can be verified rather than believed',
            ),
        ),
        migrations.AddField(
            model_name='tenantinvoice',
            name='reminders_sent',
            field=models.CharField(
                blank=True, max_length=40,
                help_text='Comma separated day counts already emailed, e.g. "14,7,3". Stops a notice going twice.',
            ),
        ),
    ]
