# Generated by Django 6.0 on 2026-01-10 18:47

import django.core.validators
import django.db.models.deletion
import django.utils.timezone
import uuid
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('master_admin', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Area',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('local_name', models.CharField(blank=True, max_length=100, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('pincode', models.CharField(blank=True, max_length=20, null=True)),
                ('zone', models.CharField(blank=True, max_length=50, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
            ],
            options={
                'ordering': ['city', 'sort_order', 'name'],
            },
        ),
        migrations.CreateModel(
            name='City',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('local_name', models.CharField(blank=True, max_length=100, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('is_metro', models.BooleanField(default=False)),
                ('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
                ('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
                ('population', models.BigIntegerField(blank=True, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
            ],
            options={
                'verbose_name_plural': 'Cities',
                'ordering': ['state', 'sort_order', 'name'],
            },
        ),
        migrations.CreateModel(
            name='SystemSetting',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=100, unique=True)),
                ('name', models.CharField(max_length=200)),
                ('description', models.TextField(blank=True, null=True)),
                ('value_type', models.CharField(choices=[('string', 'String'), ('text', 'Text'), ('integer', 'Integer'), ('float', 'Float'), ('boolean', 'Boolean'), ('json', 'JSON'), ('datetime', 'DateTime'), ('file', 'File'), ('password', 'Password'), ('url', 'URL'), ('email', 'Email')], default='string', max_length=20)),
                ('string_value', models.CharField(blank=True, max_length=500, null=True)),
                ('text_value', models.TextField(blank=True, null=True)),
                ('integer_value', models.IntegerField(blank=True, null=True)),
                ('float_value', models.FloatField(blank=True, null=True)),
                ('boolean_value', models.BooleanField(default=False)),
                ('json_value', models.JSONField(blank=True, default=dict, null=True)),
                ('datetime_value', models.DateTimeField(blank=True, null=True)),
                ('file_value', models.FileField(blank=True, null=True, upload_to='system_settings/')),
                ('is_public', models.BooleanField(default=False)),
                ('is_encrypted', models.BooleanField(default=False)),
                ('is_required', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
                ('validation_regex', models.CharField(blank=True, max_length=500, null=True)),
                ('min_value', models.FloatField(blank=True, null=True)),
                ('max_value', models.FloatField(blank=True, null=True)),
                ('options', models.JSONField(blank=True, default=dict, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['category', 'key'],
            },
        ),
        migrations.CreateModel(
            name='SystemSettingCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True, null=True)),
                ('icon', models.CharField(blank=True, max_length=100, null=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'verbose_name_plural': 'System Setting Categories',
                'ordering': ['sort_order', 'name'],
            },
        ),
        migrations.AlterModelOptions(
            name='school',
            options={'ordering': ['-created_at']},
        ),
        migrations.AddField(
            model_name='school',
            name='address_line1',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='address_line2',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='affiliation_number',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='alternate_phone',
            field=models.CharField(blank=True, max_length=20, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='banner_image',
            field=models.ImageField(blank=True, null=True, upload_to='school_banners/'),
        ),
        migrations.AddField(
            model_name='school',
            name='deleted_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='email',
            field=models.EmailField(blank=True, max_length=255, null=True, unique=True),
        ),
        migrations.AddField(
            model_name='school',
            name='established_year',
            field=models.IntegerField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='fax',
            field=models.CharField(blank=True, max_length=20, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='is_trial',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='school',
            name='landmark',
            field=models.CharField(blank=True, max_length=200, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='latitude',
            field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='logo',
            field=models.ImageField(blank=True, null=True, upload_to='school_logos/'),
        ),
        migrations.AddField(
            model_name='school',
            name='longitude',
            field=models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='metadata',
            field=models.JSONField(blank=True, default=dict, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='mission',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='motto',
            field=models.CharField(blank=True, max_length=500, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='phone',
            field=models.CharField(blank=True, max_length=20, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='prospectus',
            field=models.FileField(blank=True, null=True, upload_to='school_prospectus/'),
        ),
        migrations.AddField(
            model_name='school',
            name='registration_number',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='trial_ends_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='uuid',
            field=models.UUIDField(default=uuid.uuid4, editable=False),
        ),
        migrations.AddField(
            model_name='school',
            name='verified_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='verified_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='verified_schools', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='school',
            name='vision',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='school',
            name='website',
            field=models.URLField(blank=True, max_length=500, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='address',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='created_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='date_of_birth',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='department',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='designation',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='email_notifications',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='is_primary_contact',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='joining_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='language',
            field=models.CharField(default='en', max_length=10),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='metadata',
            field=models.JSONField(blank=True, default=dict, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='phone',
            field=models.CharField(blank=True, max_length=20, null=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='profile_picture',
            field=models.ImageField(blank=True, null=True, upload_to='profile_pictures/'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='sms_notifications',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='timezone',
            field=models.CharField(default='UTC', max_length=50),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='updated_at',
            field=models.DateTimeField(auto_now=True),
        ),
        migrations.AlterField(
            model_name='school',
            name='created_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='school',
            name='db_name',
            field=models.CharField(default='default_db', max_length=100, unique=True),
        ),
        migrations.AlterField(
            model_name='school',
            name='db_password',
            field=models.CharField(default='password', max_length=255),
        ),
        migrations.AlterField(
            model_name='school',
            name='db_user',
            field=models.CharField(default='postgres', max_length=100),
        ),
        migrations.AlterUniqueTogether(
            name='userprofile',
            unique_together={('user', 'school')},
        ),
        migrations.AddField(
            model_name='school',
            name='area',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.area'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='area',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='master_admin.area'),
        ),
        migrations.AddField(
            model_name='area',
            name='city',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='areas', to='master_admin.city'),
        ),
        migrations.AddField(
            model_name='school',
            name='city',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.city'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='city',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='master_admin.city'),
        ),
        migrations.CreateModel(
            name='Country',
            fields=[
                ('code', models.CharField(max_length=3, primary_key=True, serialize=False, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('phone_code', models.CharField(blank=True, max_length=10, null=True)),
                ('currency_code', models.CharField(blank=True, max_length=3, null=True)),
                ('currency_symbol', models.CharField(blank=True, max_length=10, null=True)),
                ('timezone', models.CharField(blank=True, max_length=50, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
            ],
            options={
                'verbose_name_plural': 'Countries',
                'ordering': ['sort_order', 'name'],
                'indexes': [models.Index(fields=['code'], name='master_admi_code_1e3a82_idx'), models.Index(fields=['name'], name='master_admi_name_70132d_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_9e3710_idx')],
            },
        ),
        migrations.AddField(
            model_name='school',
            name='country',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.country'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='country',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='master_admin.country'),
        ),
        migrations.CreateModel(
            name='Feature',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=100, unique=True)),
                ('name', models.CharField(max_length=200)),
                ('category', models.CharField(choices=[('academic', 'Academic'), ('administrative', 'Administrative'), ('financial', 'Financial'), ('communication', 'Communication'), ('analytics', 'Analytics'), ('integration', 'Integration'), ('security', 'Security')], default='academic', max_length=50)),
                ('description', models.TextField(blank=True, null=True)),
                ('icon', models.CharField(blank=True, max_length=100, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('is_core', models.BooleanField(default=False)),
                ('requires_configuration', models.BooleanField(default=False)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['category', 'name'],
                'indexes': [models.Index(fields=['code'], name='master_admi_code_e949ed_idx'), models.Index(fields=['category'], name='master_admi_categor_37c0c8_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_2abaf7_idx')],
            },
        ),
        migrations.CreateModel(
            name='PaymentType',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(choices=[('credit_card', 'Credit Card'), ('debit_card', 'Debit Card'), ('bank_transfer', 'Bank Transfer'), ('upi', 'UPI'), ('net_banking', 'Net Banking'), ('wallet', 'Digital Wallet'), ('cash', 'Cash'), ('cheque', 'Cheque'), ('paypal', 'PayPal'), ('stripe', 'Stripe'), ('razorpay', 'Razorpay'), ('other', 'Other')], max_length=50, unique=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('requires_online', models.BooleanField(default=False)),
                ('processing_fee_percentage', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=5)),
                ('min_amount', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('max_amount', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('api_key', models.TextField(blank=True, null=True)),
                ('api_secret', models.TextField(blank=True, null=True)),
                ('webhook_secret', models.TextField(blank=True, null=True)),
                ('is_test_mode', models.BooleanField(default=False)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'indexes': [models.Index(fields=['code'], name='master_admi_code_ba4a66_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_dc9ccf_idx')],
            },
        ),
        migrations.CreateModel(
            name='Pincode',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('pincode', models.CharField(max_length=20, unique=True)),
                ('is_active', models.BooleanField(default=True)),
                ('delivery_office', models.CharField(blank=True, max_length=200, null=True)),
                ('delivery_status', models.CharField(blank=True, max_length=50, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('area', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pincodes', to='master_admin.area')),
            ],
            options={
                'ordering': ['pincode'],
            },
        ),
        migrations.AddField(
            model_name='school',
            name='pincode',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.pincode'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='pincode',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='master_admin.pincode'),
        ),
        migrations.CreateModel(
            name='Plan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=50, unique=True)),
                ('tier', models.CharField(choices=[('free', 'Free'), ('basic', 'Basic'), ('standard', 'Standard'), ('premium', 'Premium'), ('enterprise', 'Enterprise'), ('custom', 'Custom')], default='basic', max_length=20)),
                ('description', models.TextField(blank=True, null=True)),
                ('price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])),
                ('billing_cycle', models.CharField(choices=[('monthly', 'Monthly'), ('yearly', 'Yearly'), ('quarterly', 'Quarterly'), ('half_yearly', 'Half Yearly'), ('lifetime', 'Lifetime')], default='monthly', max_length=20)),
                ('currency', models.CharField(default='USD', max_length=3)),
                ('max_students', models.IntegerField(default=0)),
                ('max_staff', models.IntegerField(default=0)),
                ('max_storage_mb', models.IntegerField(default=1024)),
                ('max_branches', models.IntegerField(default=1)),
                ('max_classes', models.IntegerField(default=10)),
                ('max_subjects', models.IntegerField(default=50)),
                ('max_users', models.IntegerField(default=0)),
                ('is_active', models.BooleanField(default=True)),
                ('is_visible', models.BooleanField(default=True)),
                ('is_popular', models.BooleanField(default=False)),
                ('sort_order', models.IntegerField(default=0)),
                ('trial_days', models.IntegerField(default=14)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['sort_order', 'price'],
                'indexes': [models.Index(fields=['code'], name='master_admi_code_605185_idx'), models.Index(fields=['tier'], name='master_admi_tier_f01b36_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_419165_idx'), models.Index(fields=['price'], name='master_admi_price_cde06a_idx')],
            },
        ),
        migrations.CreateModel(
            name='PlanFeature',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_enabled', models.BooleanField(default=True)),
                ('limit_value', models.IntegerField(blank=True, null=True)),
                ('is_addon', models.BooleanField(default=False)),
                ('addon_price', models.DecimalField(blank=True, decimal_places=2, default=Decimal('0.00'), max_digits=10, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])),
                ('current_usage', models.IntegerField(default=0)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('notes', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('feature', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='feature_plans', to='master_admin.feature')),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='plan_features', to='master_admin.plan')),
            ],
        ),
        migrations.CreateModel(
            name='SchoolBoard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('board_type', models.CharField(choices=[('national', 'National'), ('state', 'State'), ('international', 'International'), ('other', 'Other')], default='state', max_length=20)),
                ('description', models.TextField(blank=True, null=True)),
                ('website', models.URLField(blank=True, null=True)),
                ('logo', models.ImageField(blank=True, null=True, upload_to='board_logos/')),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('has_streams', models.BooleanField(default=False)),
                ('has_elective_subjects', models.BooleanField(default=False)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='school_boards', to='master_admin.country')),
            ],
            options={
                'ordering': ['sort_order', 'name'],
            },
        ),
        migrations.AddField(
            model_name='school',
            name='school_board',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.schoolboard'),
        ),
        migrations.CreateModel(
            name='SchoolLevel',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('short_name', models.CharField(blank=True, max_length=20, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('duration_years', models.IntegerField(default=2)),
                ('start_grade', models.IntegerField(default=1)),
                ('end_grade', models.IntegerField(default=10)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
            ],
            options={
                'ordering': ['sort_order', 'start_grade'],
                'indexes': [models.Index(fields=['code'], name='master_admi_code_a4093c_idx'), models.Index(fields=['name'], name='master_admi_name_658382_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_c4c34e_idx'), models.Index(fields=['start_grade'], name='master_admi_start_g_cbdd5f_idx')],
            },
        ),
        migrations.AddField(
            model_name='school',
            name='school_level',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.schoollevel'),
        ),
        migrations.CreateModel(
            name='SchoolSubscription',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField(default=django.utils.timezone.now)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('status', models.CharField(choices=[('trial', 'Trial'), ('active', 'Active'), ('pending', 'Pending'), ('expired', 'Expired'), ('cancelled', 'Cancelled'), ('suspended', 'Suspended')], default='trial', max_length=20)),
                ('is_auto_renew', models.BooleanField(default=True)),
                ('subscribed_price', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])),
                ('currency', models.CharField(default='USD', max_length=3)),
                ('discount_applied', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('billing_cycle', models.CharField(choices=[('monthly', 'Monthly'), ('yearly', 'Yearly'), ('quarterly', 'Quarterly'), ('half_yearly', 'Half Yearly'), ('lifetime', 'Lifetime')], default='monthly', max_length=20)),
                ('next_billing_date', models.DateField(blank=True, null=True)),
                ('cancelled_at', models.DateTimeField(blank=True, null=True)),
                ('cancellation_reason', models.TextField(blank=True, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('notes', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('plan', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='school_subscriptions', to='master_admin.plan')),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='master_admin.school')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Payment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('payment_reference', models.CharField(max_length=100, unique=True)),
                ('amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])),
                ('currency', models.CharField(default='USD', max_length=3)),
                ('processing_fee', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('tax_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('total_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))])),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('processing', 'Processing'), ('completed', 'Completed'), ('failed', 'Failed'), ('refunded', 'Refunded'), ('partially_refunded', 'Partially Refunded'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('payment_gateway', models.CharField(choices=[('stripe', 'Stripe'), ('razorpay', 'Razorpay'), ('paypal', 'PayPal'), ('manual', 'Manual'), ('other', 'Other')], default='manual', max_length=20)),
                ('gateway_reference', models.CharField(blank=True, max_length=200, null=True)),
                ('gateway_response', models.JSONField(blank=True, default=dict, null=True)),
                ('payment_date', models.DateTimeField(blank=True, null=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('billing_period_start', models.DateField(blank=True, null=True)),
                ('billing_period_end', models.DateField(blank=True, null=True)),
                ('invoice_number', models.CharField(blank=True, max_length=100, null=True)),
                ('invoice_url', models.URLField(blank=True, max_length=500, null=True)),
                ('receipt_url', models.URLField(blank=True, max_length=500, null=True)),
                ('refund_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
                ('refund_reason', models.TextField(blank=True, null=True)),
                ('refunded_at', models.DateTimeField(blank=True, null=True)),
                ('payer_name', models.CharField(blank=True, max_length=255, null=True)),
                ('payer_email', models.EmailField(blank=True, max_length=254, null=True)),
                ('payer_phone', models.CharField(blank=True, max_length=20, null=True)),
                ('notes', models.TextField(blank=True, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('created_at', models.DateTimeField(blank=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='master_admin.school')),
                ('payment_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='payments', to='master_admin.paymenttype')),
                ('subscription', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='payments', to='master_admin.schoolsubscription')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SchoolType',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('institution_type', models.CharField(choices=[('preschool', 'Preschool/Nursery'), ('primary', 'Primary School'), ('middle', 'Middle School'), ('secondary', 'Secondary School'), ('higher_secondary', 'Higher Secondary'), ('k12', 'K-12 School'), ('junior_college', 'Junior College'), ('college', 'College'), ('university', 'University'), ('vocational', 'Vocational Institute'), ('coaching', 'Coaching Center'), ('other', 'Other')], max_length=50)),
                ('ownership', models.CharField(choices=[('government', 'Government'), ('private', 'Private'), ('aided', 'Government Aided'), ('trust', 'Trust'), ('society', 'Society'), ('other', 'Other')], default='private', max_length=50)),
                ('gender_type', models.CharField(choices=[('coed', 'Co-educational'), ('boys', 'Boys Only'), ('girls', 'Girls Only')], default='coed', max_length=50)),
                ('description', models.TextField(blank=True, null=True)),
                ('min_grade', models.IntegerField(blank=True, null=True)),
                ('max_grade', models.IntegerField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
            ],
            options={
                'ordering': ['sort_order', 'name'],
                'indexes': [models.Index(fields=['code'], name='master_admi_code_b614f0_idx'), models.Index(fields=['name'], name='master_admi_name_0f665b_idx'), models.Index(fields=['institution_type'], name='master_admi_institu_701097_idx'), models.Index(fields=['ownership'], name='master_admi_ownersh_63aa0a_idx'), models.Index(fields=['is_active'], name='master_admi_is_acti_56c9e4_idx')],
            },
        ),
        migrations.AddField(
            model_name='school',
            name='school_type',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.schooltype'),
        ),
        migrations.CreateModel(
            name='State',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(blank=True, max_length=10, null=True)),
                ('name', models.CharField(max_length=100)),
                ('local_name', models.CharField(blank=True, max_length=100, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('sort_order', models.IntegerField(default=0)),
                ('capital', models.CharField(blank=True, max_length=100, null=True)),
                ('area_sq_km', models.FloatField(blank=True, null=True)),
                ('population', models.BigIntegerField(blank=True, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict, null=True)),
                ('country', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='states', to='master_admin.country')),
            ],
            options={
                'ordering': ['country', 'sort_order', 'name'],
            },
        ),
        migrations.AddField(
            model_name='city',
            name='state',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cities', to='master_admin.state'),
        ),
        migrations.AddField(
            model_name='school',
            name='state',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='schools', to='master_admin.state'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='state',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='master_admin.state'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['slug'], name='master_admi_slug_912d3c_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['domain_name'], name='master_admi_domain__d10295_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['email'], name='master_admi_email_f55859_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_2f4898_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['is_trial'], name='master_admi_is_tria_99472f_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['created_at'], name='master_admi_created_8c6873_idx'),
        ),
        migrations.AddIndex(
            model_name='school',
            index=models.Index(fields=['school_type', 'school_board'], name='master_admi_school__d4e71d_idx'),
        ),
        migrations.AddIndex(
            model_name='userprofile',
            index=models.Index(fields=['user', 'school'], name='master_admi_user_id_a70fb4_idx'),
        ),
        migrations.AddIndex(
            model_name='userprofile',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_1c0bdc_idx'),
        ),
        migrations.AddIndex(
            model_name='userprofile',
            index=models.Index(fields=['external_id'], name='master_admi_externa_ef1068_idx'),
        ),
        migrations.AddIndex(
            model_name='userprofile',
            index=models.Index(fields=['designation'], name='master_admi_designa_15ac4a_idx'),
        ),
        migrations.AddConstraint(
            model_name='school',
            constraint=models.UniqueConstraint(fields=('uuid',), name='unique_school_uuid'),
        ),
        migrations.AddField(
            model_name='systemsetting',
            name='last_modified_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddIndex(
            model_name='systemsettingcategory',
            index=models.Index(fields=['code'], name='master_admi_code_f21b0c_idx'),
        ),
        migrations.AddIndex(
            model_name='systemsettingcategory',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_b9e739_idx'),
        ),
        migrations.AddField(
            model_name='systemsetting',
            name='category',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='settings', to='master_admin.systemsettingcategory'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['city', 'name'], name='master_admi_city_id_e26a8b_idx'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['name'], name='master_admi_name_436847_idx'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['pincode'], name='master_admi_pincode_8aa06c_idx'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_2e4053_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='area',
            unique_together={('city', 'name')},
        ),
        migrations.AddIndex(
            model_name='pincode',
            index=models.Index(fields=['pincode'], name='master_admi_pincode_33f1de_idx'),
        ),
        migrations.AddIndex(
            model_name='pincode',
            index=models.Index(fields=['area', 'pincode'], name='master_admi_area_id_115391_idx'),
        ),
        migrations.AddIndex(
            model_name='pincode',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_c287d2_idx'),
        ),
        migrations.AddIndex(
            model_name='planfeature',
            index=models.Index(fields=['plan', 'feature'], name='master_admi_plan_id_bd23bf_idx'),
        ),
        migrations.AddIndex(
            model_name='planfeature',
            index=models.Index(fields=['is_enabled'], name='master_admi_is_enab_99e7c6_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='planfeature',
            unique_together={('plan', 'feature')},
        ),
        migrations.AddIndex(
            model_name='schoolboard',
            index=models.Index(fields=['code'], name='master_admi_code_cf2ad8_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolboard',
            index=models.Index(fields=['name'], name='master_admi_name_6058ad_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolboard',
            index=models.Index(fields=['board_type'], name='master_admi_board_t_efe633_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolboard',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_f1ff67_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolsubscription',
            index=models.Index(fields=['school', 'status'], name='master_admi_school__0b44fd_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolsubscription',
            index=models.Index(fields=['status'], name='master_admi_status_e14f04_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolsubscription',
            index=models.Index(fields=['end_date'], name='master_admi_end_dat_ef8f56_idx'),
        ),
        migrations.AddIndex(
            model_name='schoolsubscription',
            index=models.Index(fields=['next_billing_date'], name='master_admi_next_bi_f778d9_idx'),
        ),
        migrations.AddIndex(
            model_name='payment',
            index=models.Index(fields=['payment_reference'], name='master_admi_payment_099c50_idx'),
        ),
        migrations.AddIndex(
            model_name='payment',
            index=models.Index(fields=['school', 'status'], name='master_admi_school__0c2bb0_idx'),
        ),
        migrations.AddIndex(
            model_name='payment',
            index=models.Index(fields=['status'], name='master_admi_status_999ced_idx'),
        ),
        migrations.AddIndex(
            model_name='payment',
            index=models.Index(fields=['payment_date'], name='master_admi_payment_b1f019_idx'),
        ),
        migrations.AddIndex(
            model_name='payment',
            index=models.Index(fields=['invoice_number'], name='master_admi_invoice_0bdafc_idx'),
        ),
        migrations.AddIndex(
            model_name='state',
            index=models.Index(fields=['country', 'name'], name='master_admi_country_f88b61_idx'),
        ),
        migrations.AddIndex(
            model_name='state',
            index=models.Index(fields=['name'], name='master_admi_name_411d83_idx'),
        ),
        migrations.AddIndex(
            model_name='state',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_fd2a88_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='state',
            unique_together={('country', 'name')},
        ),
        migrations.AddIndex(
            model_name='city',
            index=models.Index(fields=['state', 'name'], name='master_admi_state_i_e50975_idx'),
        ),
        migrations.AddIndex(
            model_name='city',
            index=models.Index(fields=['name'], name='master_admi_name_79c982_idx'),
        ),
        migrations.AddIndex(
            model_name='city',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_982579_idx'),
        ),
        migrations.AddIndex(
            model_name='city',
            index=models.Index(fields=['latitude', 'longitude'], name='master_admi_latitud_3f1bb3_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='city',
            unique_together={('state', 'name')},
        ),
        migrations.AddIndex(
            model_name='systemsetting',
            index=models.Index(fields=['key'], name='master_admi_key_b657b2_idx'),
        ),
        migrations.AddIndex(
            model_name='systemsetting',
            index=models.Index(fields=['category'], name='master_admi_categor_3035fe_idx'),
        ),
        migrations.AddIndex(
            model_name='systemsetting',
            index=models.Index(fields=['is_active'], name='master_admi_is_acti_a001e0_idx'),
        ),
        migrations.AddIndex(
            model_name='systemsetting',
            index=models.Index(fields=['is_public'], name='master_admi_is_publ_5294e5_idx'),
        ),
    ]
