# Generated by Django 4.2.27 on 2026-06-19 11:36
# Modified to use SeparateDatabaseAndState for RemoveIndex to bypass
# MySQL backend's _create_missing_fk_index check that fails after RenameField

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('config', '0002_rename_pinyin_to_pascal'),
    ]

    operations = [
        # RemoveIndex operations wrapped in SeparateDatabaseAndState
        # to bypass MySQL backend's FK index check that references old field names
        migrations.SeparateDatabaseAndState(
            state_operations=[
                migrations.RemoveIndex(
                    model_name='shangjialianjie',
                    name='shangjia_li_yonghu__9f2b25_idx',
                ),
                migrations.RemoveIndex(
                    model_name='shangjialianjie',
                    name='shangjia_li_lianjie_99014c_idx',
                ),
                migrations.RemoveIndex(
                    model_name='shangjialianjie',
                    name='shangjia_li_dingdan_95b682_idx',
                ),
                migrations.RemoveIndex(
                    model_name='shangjiamoban',
                    name='shangjia_mo_yonghu__bb287d_idx',
                ),
                migrations.RemoveIndex(
                    model_name='shangjiamoban',
                    name='shangjia_mo_yonghu__4240d0_idx',
                ),
            ],
            database_operations=[
                migrations.RunSQL(
                    sql=[
                        'DROP INDEX `shangjia_li_yonghu__9f2b25_idx` ON `shangjia_lianjie`',
                        'DROP INDEX `shangjia_li_lianjie_99014c_idx` ON `shangjia_lianjie`',
                        'DROP INDEX `shangjia_li_dingdan_95b682_idx` ON `shangjia_lianjie`',
                        'DROP INDEX `shangjia_mo_yonghu__bb287d_idx` ON `shangjia_moban`',
                        'DROP INDEX `shangjia_mo_yonghu__4240d0_idx` ON `shangjia_moban`',
                    ],
                    reverse_sql=[
                        # No reverse needed - indexes will be recreated by AddIndex
                    ],
                ),
            ],
        ),
        # AddIndex operations - these should work fine since fields exist with new names
        migrations.AddIndex(
            model_name='shangjialianjie',
            index=models.Index(fields=['UserID', 'TemplateID', 'ProductTypeID'], name='shangjia_li_UserID_e59d94_idx'),
        ),
        migrations.AddIndex(
            model_name='shangjialianjie',
            index=models.Index(fields=['LinkToken'], name='shangjia_li_LinkTok_6b32bb_idx'),
        ),
        migrations.AddIndex(
            model_name='shangjialianjie',
            index=models.Index(fields=['OrderID'], name='shangjia_li_OrderID_e7ddf9_idx'),
        ),
        migrations.AddIndex(
            model_name='shangjiamoban',
            index=models.Index(fields=['UserID', 'ProductTypeID'], name='shangjia_mo_UserID_abd699_idx'),
        ),
        migrations.AddIndex(
            model_name='shangjiamoban',
            index=models.Index(fields=['UserID', 'ProductTypeID', 'id'], name='shangjia_mo_UserID_2dcb54_idx'),
        ),
    ]
