旧 forward 用 target.favorability == 10 判断"未迁移",10 既是初始值也是衰减 常见值,重跑会覆盖合法数据;backward 用 != 10 反向判断会丢衰减回 10 的数据。 改用 AffinityLog source='data_migration' 标记做幂等: - forward 写入新值时同步写一条 audit log,metadata 含原 ParadiseUser 值 - backward 遍历 audit log 反向恢复并删除标记,保证 forward/backward 可循环 同步:AffinityLog.SOURCE_CHOICES 追加 'data_migration' + 0008 AlterField 迁移 更新 Python 端 choices 校验。 option B 选择:直接重写 0006(dev 已跑过但 migrate_count=0 等于未动数据, django_migrations 表已记录完成不会再跑)。生产部署前需确认 prod 未跑过 0006, 否则需 fake-reverse 流程,详见迁移文件 docstring 与 FIX-REPORT。 详见 docs/REVIEW-affinity-P1.md CR-003。
19 lines
698 B
Python
19 lines
698 B
Python
# Generated by Django 5.2.12 on 2026-05-13 02:12
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('userapp', '0007_add_affinity_check_constraints'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AlterField(
|
|
model_name='affinitylog',
|
|
name='source',
|
|
field=models.CharField(choices=[('device_event', '设备端事件'), ('mobile_event', '手机端事件'), ('system_decay', '系统衰减'), ('admin_adjust_single', '管理员单次调整'), ('admin_adjust_batch', '管理员批量调整'), ('data_migration', '数据迁移')], max_length=30, verbose_name='来源'),
|
|
),
|
|
]
|