# Generated manually for club migrate module

from decimal import Decimal

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('jituan', '0020_order_deal_config_stats'),
    ]

    operations = [
        migrations.CreateModel(
            name='ClubMigratePlan',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plan_id', models.CharField(db_index=True, max_length=32, unique=True, verbose_name='计划ID')),
                ('name', models.CharField(blank=True, default='', max_length=64, verbose_name='计划名称')),
                ('from_club_id', models.CharField(db_index=True, max_length=16, verbose_name='源俱乐部')),
                ('to_club_id', models.CharField(db_index=True, max_length=16, verbose_name='目标俱乐部')),
                ('enabled', models.BooleanField(db_index=True, default=False, verbose_name='是否启用')),
                ('start_at', models.DateTimeField(blank=True, null=True, verbose_name='开始时间')),
                ('end_at', models.DateTimeField(blank=True, null=True, verbose_name='结束时间')),
                ('asset_whitelist', models.JSONField(blank=True, default=list, verbose_name='资产白名单')),
                ('condition_json', models.JSONField(blank=True, default=dict, verbose_name='门槛条件')),
                ('force_intercept', models.BooleanField(default=True, verbose_name='源店强制迁移页')),
                ('force_roles', models.JSONField(blank=True, default=list, verbose_name='强制角色列表')),
                ('default_once_per_user', models.BooleanField(default=True, verbose_name='默认每人成功一次')),
                ('remark', models.CharField(blank=True, default='', max_length=255)),
                ('updated_by', models.CharField(blank=True, default='', max_length=32)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '跨店资产迁移计划',
                'db_table': 'club_migrate_plan',
            },
        ),
        migrations.CreateModel(
            name='ClubMigrateToken',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.CharField(db_index=True, max_length=64, unique=True, verbose_name='令牌')),
                ('plan_id', models.CharField(db_index=True, max_length=32)),
                ('from_club_id', models.CharField(db_index=True, max_length=16)),
                ('to_club_id', models.CharField(db_index=True, max_length=16)),
                ('from_uid', models.CharField(db_index=True, max_length=16, verbose_name='源UserUID')),
                ('password_hash', models.CharField(blank=True, default='', max_length=128, verbose_name='转移密码哈希')),
                ('password_salt', models.CharField(blank=True, default='', max_length=32)),
                ('status', models.SmallIntegerField(db_index=True, default=0)),
                ('fail_count', models.PositiveIntegerField(default=0, verbose_name='验密失败次数')),
                ('asset_snapshot', models.JSONField(blank=True, default=dict, verbose_name='发码时资产快照')),
                ('qrcode_url', models.CharField(blank=True, default='', max_length=512, verbose_name='目标店小程序码URL')),
                ('expire_at', models.DateTimeField(blank=True, db_index=True, null=True)),
                ('consumed_at', models.DateTimeField(blank=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '跨店迁移令牌',
                'db_table': 'club_migrate_token',
            },
        ),
        migrations.CreateModel(
            name='ClubMigrateConsumption',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plan_id', models.CharField(db_index=True, max_length=32)),
                ('from_uid', models.CharField(db_index=True, max_length=16)),
                ('success_count', models.PositiveIntegerField(default=0)),
                ('last_ledger_id', models.BigIntegerField(blank=True, null=True)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '跨店迁移占用',
                'db_table': 'club_migrate_consumption',
                'unique_together': {('plan_id', 'from_uid')},
            },
        ),
        migrations.CreateModel(
            name='ClubMigrateUserQuota',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plan_id', models.CharField(db_index=True, max_length=32)),
                ('from_uid', models.CharField(db_index=True, max_length=16)),
                ('max_extra_times', models.PositiveIntegerField(default=1, verbose_name='额外成功次数')),
                ('reason', models.CharField(blank=True, default='', max_length=255)),
                ('updated_by', models.CharField(blank=True, default='', max_length=32)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '跨店迁移二次白名单',
                'db_table': 'club_migrate_user_quota',
                'unique_together': {('plan_id', 'from_uid')},
            },
        ),
        migrations.CreateModel(
            name='ClubMigrateLedger',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plan_id', models.CharField(db_index=True, max_length=32)),
                ('token', models.CharField(blank=True, db_index=True, default='', max_length=64)),
                ('from_club_id', models.CharField(db_index=True, max_length=16)),
                ('to_club_id', models.CharField(db_index=True, max_length=16)),
                ('from_uid', models.CharField(db_index=True, max_length=16)),
                ('to_uid', models.CharField(db_index=True, max_length=16)),
                ('migrate_seq', models.PositiveIntegerField(default=1, verbose_name='本计划第几次')),
                ('status', models.SmallIntegerField(db_index=True, default=1)),
                ('summary_json', models.JSONField(blank=True, default=dict, verbose_name='摘要')),
                ('client_meta', models.JSONField(blank=True, default=dict)),
                ('CreateTime', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('UpdateTime', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': '跨店迁移流水主单',
                'db_table': 'club_migrate_ledger',
            },
        ),
        migrations.CreateModel(
            name='ClubMigrateLedgerItem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ledger_id', models.BigIntegerField(db_index=True)),
                ('plan_id', models.CharField(db_index=True, max_length=32)),
                ('item_type', models.CharField(db_index=True, default='balance', max_length=16)),
                ('role', models.CharField(db_index=True, max_length=16)),
                ('field', models.CharField(blank=True, default='', max_length=32, verbose_name='字段名')),
                ('amount', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=14)),
                ('before_src', models.CharField(blank=True, default='', max_length=64)),
                ('after_src', models.CharField(blank=True, default='', max_length=64)),
                ('before_dst', models.CharField(blank=True, default='', max_length=64)),
                ('after_dst', models.CharField(blank=True, default='', max_length=64)),
                ('huiyuan_id', models.CharField(blank=True, db_index=True, default='', max_length=16)),
                ('meta_json', models.JSONField(blank=True, default=dict)),
                ('CreateTime', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'verbose_name': '跨店迁移流水明细',
                'db_table': 'club_migrate_ledger_item',
            },
        ),
        migrations.AddIndex(
            model_name='clubmigrateplan',
            index=models.Index(fields=['from_club_id', 'enabled'], name='idx_cmp_from_en'),
        ),
        migrations.AddIndex(
            model_name='clubmigrateplan',
            index=models.Index(fields=['to_club_id', 'enabled'], name='idx_cmp_to_en'),
        ),
        migrations.AddIndex(
            model_name='clubmigratetoken',
            index=models.Index(fields=['plan_id', 'from_uid', 'status'], name='idx_cmt_plan_uid_st'),
        ),
        migrations.AddIndex(
            model_name='clubmigrateledger',
            index=models.Index(fields=['from_uid', 'plan_id'], name='idx_cml_from_plan'),
        ),
        migrations.AddIndex(
            model_name='clubmigrateledger',
            index=models.Index(fields=['to_uid', 'plan_id'], name='idx_cml_to_plan'),
        ),
        migrations.AddIndex(
            model_name='clubmigrateledger',
            index=models.Index(fields=['from_club_id', 'to_club_id', 'CreateTime'], name='idx_cml_clubs_t'),
        ),
        migrations.AddIndex(
            model_name='clubmigrateledgeritem',
            index=models.Index(fields=['ledger_id', 'role'], name='idx_cmli_led_role'),
        ),
    ]
