# Generated by Django 5.2.16 on 2026-08-11 23:08

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


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0001_initial'),
        ('core', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Member',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('member_number', models.CharField(blank=True, max_length=20, unique=True)),
                ('first_name', models.CharField(max_length=80)),
                ('other_names', models.CharField(blank=True, max_length=100)),
                ('last_name', models.CharField(max_length=80)),
                ('gender', models.CharField(blank=True, max_length=20)),
                ('nationality', models.CharField(blank=True, max_length=100)),
                ('campus_name_raw', models.CharField(blank=True, max_length=180)),
                ('primary_phone', models.CharField(max_length=20, unique=True)),
                ('alternate_phone', models.CharField(blank=True, max_length=20)),
                ('church_branch', models.CharField(blank=True, max_length=150)),
                ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('INACTIVE', 'Inactive'), ('DECEASED', 'Deceased')], default='ACTIVE', max_length=15)),
                ('account_status', models.CharField(choices=[('PENDING', 'Credentials not sent'), ('INVITED', 'Invitation sent'), ('ACTIVE', 'Account activated'), ('DISABLED', 'Account disabled')], default='PENDING', max_length=15)),
                ('source', models.CharField(blank=True, max_length=100)),
                ('imported_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('campus', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='member_records', to='core.campus')),
                ('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='member_records', to='core.country')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='member_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['first_name', 'last_name'],
            },
        ),
        migrations.CreateModel(
            name='AccountInvitation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token_hash', models.CharField(max_length=64, unique=True)),
                ('channel', models.CharField(choices=[('SMS', 'SMS'), ('EMAIL', 'Email')], default='SMS', max_length=10)),
                ('destination', models.CharField(max_length=254)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('SENT', 'Sent'), ('FAILED', 'Failed'), ('ACCEPTED', 'Accepted'), ('EXPIRED', 'Expired')], default='PENDING', max_length=12)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('sent_at', models.DateTimeField(blank=True, null=True)),
                ('expires_at', models.DateTimeField()),
                ('accepted_at', models.DateTimeField(blank=True, null=True)),
                ('error', models.TextField(blank=True)),
                ('sent_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='account_invitations_sent', to=settings.AUTH_USER_MODEL)),
                ('member', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='account_invitations', to='accounts.member')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='member',
            index=models.Index(fields=['account_status'], name='accounts_me_account_2f44a9_idx'),
        ),
        migrations.AddIndex(
            model_name='member',
            index=models.Index(fields=['church_branch'], name='accounts_me_church__e2e08e_idx'),
        ),
    ]
