累死了,删除了所有跨平台逻辑,进行了表迁移

This commit is contained in:
2026-06-15 02:09:51 +08:00
parent 8b9dbcba6f
commit 9eb53ee57d
112 changed files with 468 additions and 6208 deletions

35
fix_migration_history.py Normal file
View File

@@ -0,0 +1,35 @@
"""
修复 django_migrations 表中的旧 app 名称引用。
在服务器上执行: python manage.py shell < fix_migration_history.py
或: python manage.py shell
然后粘贴此脚本内容
"""
from django.db import connection
APP_NAME_MAPPINGS = {
'houtai': 'backend',
'yonghu': 'users',
'dingdan': 'orders',
'peizhi': 'config',
'shangpin': 'products',
'shangdian': 'shop',
'dengji': 'rank',
}
with connection.cursor() as cursor:
for old_name, new_name in APP_NAME_MAPPINGS.items():
cursor.execute(
"SELECT COUNT(*) FROM django_migrations WHERE app = %s",
[old_name]
)
count = cursor.fetchone()[0]
if count > 0:
cursor.execute(
"UPDATE django_migrations SET app = %s WHERE app = %s",
[new_name, old_name]
)
print(f"已更新 {count} 条记录: {old_name} -> {new_name}")
else:
print(f"无需更新: {old_name} (无记录)")
print("\n修复完成!请运行 python manage.py migrate")