# Generated by Django 5.2.8 on 2025-11-28 08:06

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('core', '0007_add_tenant_permissions'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='TenantInvitation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('email', models.EmailField(help_text='Email address to send invitation to', max_length=254)),
                ('token', models.CharField(max_length=64, unique=True)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('ACCEPTED', 'Accepted'), ('EXPIRED', 'Expired'), ('CANCELLED', 'Cancelled')], default='PENDING', max_length=20)),
                ('suggested_business_name', models.CharField(blank=True, help_text='Suggested business name (owner can change during onboarding)', max_length=100)),
                ('subscription_tier', models.CharField(choices=[('FREE', 'Free Trial'), ('STARTER', 'Starter'), ('PROFESSIONAL', 'Professional'), ('ENTERPRISE', 'Enterprise')], default='PROFESSIONAL', max_length=50)),
                ('custom_max_users', models.IntegerField(blank=True, help_text='Custom max users limit (null = use tier default)', null=True)),
                ('custom_max_resources', models.IntegerField(blank=True, help_text='Custom max resources limit (null = use tier default)', null=True)),
                ('permissions', models.JSONField(blank=True, default=dict, help_text='Platform permissions to grant (e.g., can_accept_payments, can_use_custom_domain)')),
                ('personal_message', models.TextField(blank=True, help_text='Optional personal message to include in the invitation email')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('expires_at', models.DateTimeField()),
                ('accepted_at', models.DateTimeField(blank=True, null=True)),
                ('created_tenant', models.ForeignKey(blank=True, help_text='Tenant created when invitation was accepted', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invitation', to='core.tenant')),
                ('created_user', models.ForeignKey(blank=True, help_text='Owner user created when invitation was accepted', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tenant_invitation_accepted', to=settings.AUTH_USER_MODEL)),
                ('invited_by', models.ForeignKey(help_text='Platform admin who sent the invitation', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tenant_invitations_sent', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['token'], name='platform_ad_token_7ec24c_idx'), models.Index(fields=['email', 'status'], name='platform_ad_email_309f0f_idx'), models.Index(fields=['status', 'expires_at'], name='platform_ad_status_f2fa75_idx')],
            },
        ),
    ]
