fix: wechat or phone decrypt err

pull/15983/head^2
ibuler 2025-09-04 11:50:01 +08:00 committed by 老广
parent 7a6187b95f
commit 60f06adaa9
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
from django.db import migrations
def fix_user_wechat_phone(apps, schema_editor):
User = apps.get_model("users", "User")
users = User.objects.all()
for user in users:
update_fields = []
if user.wechat and '==' in user.wechat and len(user.wechat) > 40:
user.wechat = ''
update_fields.append("wechat")
if user.phone and '==' in user.phone and len(user.phone) > 40:
user.phone = ''
update_fields.append("phone")
if update_fields:
user.save(update_fields=update_fields)
class Migration(migrations.Migration):
dependencies = [
('users', '0003_alter_user_date_expired'),
]
operations = [
migrations.RunPython(fix_user_wechat_phone),
]