# Generated by Django 5.2.9 on 2025-12-09 13:28

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('investments', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Commission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('level', models.IntegerField()),
                ('commission_rate', models.DecimalField(decimal_places=2, max_digits=5)),
                ('amount', models.DecimalField(decimal_places=8, max_digits=20)),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('distributed', 'Distributed')], default='pending', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('distributed_at', models.DateTimeField(blank=True, null=True)),
                ('downline_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions_paid', to=settings.AUTH_USER_MODEL)),
                ('reward', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions', to='investments.reward')),
                ('upline_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions_earned', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'commissions',
                'indexes': [models.Index(fields=['upline_user', 'status'], name='commissions_upline__cdfa82_idx'), models.Index(fields=['reward', 'level'], name='commissions_reward__d9aa8d_idx')],
            },
        ),
    ]
