# Generated by Django 5.2.19 on 2026-11-16 14:50 import django.db.models.deletion import django.db.models.functions.text import django.db.models.lookups import django.utils.timezone from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('lottery', '0003_console_and_reports'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Utxo', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('txid', models.CharField(max_length=64)), ('vout', models.PositiveIntegerField()), ('amount_sats', models.BigIntegerField()), ('address', models.CharField(max_length=128)), ('confirmed_height', models.PositiveIntegerField(blank=True, null=True)), ('spent_txid', models.CharField(blank=True, max_length=64, null=True)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('reserved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='reserved_utxos', to='lottery.chaintransaction')), ('round', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='utxos', to='lottery.round')), ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='utxos', to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='Deposit', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('status', models.CharField(choices=[('detected', 'Detected'), ('credited', 'Credited'), ('orphaned', 'Orphaned')], default='detected', max_length=16)), ('detected_at', models.DateTimeField(default=django.utils.timezone.now)), ('credited_at', models.DateTimeField(blank=True, null=True)), ('movement', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='deposit', to='lottery.movement')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='deposits', to=settings.AUTH_USER_MODEL)), ('utxo', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='deposit', to='lottery.utxo')), ], ), migrations.CreateModel( name='DepositAddress', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('derivation_index', models.PositiveIntegerField(unique=True)), ('address', models.CharField(max_length=128, unique=True)), ('network', models.CharField(max_length=16)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='deposit_address', to=settings.AUTH_USER_MODEL)), ], options={ 'constraints': [models.CheckConstraint(condition=models.Q(('network__in', ['mainnet', 'regtest'])), name='lottery_depositaddress_network_valid')], }, ), migrations.CreateModel( name='TransactionVersion', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('txid', models.CharField(max_length=64, unique=True)), ('raw_hex', models.TextField(blank=True, default='')), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), ('transaction', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='versions', to='lottery.chaintransaction')), ], options={ 'constraints': [models.CheckConstraint(condition=django.db.models.lookups.Exact(django.db.models.functions.text.Length('txid'), 64), name='lottery_txversion_txid_length')], }, ), migrations.AddIndex( model_name='utxo', index=models.Index(fields=['address'], name='lottery_utx_address_daa4dd_idx'), ), migrations.AddIndex( model_name='utxo', index=models.Index(fields=['user'], name='lottery_utx_user_id_2ccdc9_idx'), ), migrations.AddConstraint( model_name='utxo', constraint=models.UniqueConstraint(fields=('txid', 'vout'), name='lottery_utxo_outpoint_unique'), ), migrations.AddConstraint( model_name='utxo', constraint=models.CheckConstraint(condition=models.Q(('amount_sats__gt', 0)), name='lottery_utxo_amount_positive'), ), migrations.AddConstraint( model_name='utxo', constraint=models.CheckConstraint(condition=django.db.models.lookups.Exact(django.db.models.functions.text.Length('txid'), 64), name='lottery_utxo_txid_length'), ), migrations.AddConstraint( model_name='utxo', constraint=models.CheckConstraint(condition=models.Q(('spent_txid__isnull', True), django.db.models.lookups.Exact(django.db.models.functions.text.Length('spent_txid'), 64), _connector='OR'), name='lottery_utxo_spent_txid_length'), ), migrations.AddConstraint( model_name='utxo', constraint=models.CheckConstraint(condition=models.Q(('user__isnull', True), ('round__isnull', True), _connector='OR'), name='lottery_utxo_user_or_round'), ), migrations.AddConstraint( model_name='deposit', constraint=models.CheckConstraint(condition=models.Q(('status__in', ['detected', 'credited', 'orphaned'])), name='lottery_deposit_status_valid'), ), migrations.AddConstraint( model_name='deposit', constraint=models.CheckConstraint(condition=models.Q(models.Q(('status', 'credited'), _negated=True), models.Q(('movement__isnull', False), ('credited_at__isnull', False)), _connector='OR'), name='lottery_deposit_credited_has_movement'), ), ]