Fix migration error
This commit is contained in:
83
complete_migration_reset.py
Normal file
83
complete_migration_reset.py
Normal file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
チーム・エントリーデータ完全リセット&再移行スクリプト
|
||||
既存のTeam/Entryデータをクリアして、old_rogdbから完全に移行し直す
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import django
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from rog.models import Team, Entry, Member
|
||||
from django.db import transaction
|
||||
import subprocess
|
||||
|
||||
print("=== チーム・エントリーデータ完全リセット&再移行 ===")
|
||||
|
||||
try:
|
||||
with transaction.atomic():
|
||||
print("1. 既存データをクリア中...")
|
||||
|
||||
# 関連データを順番にクリア
|
||||
entry_count = Entry.objects.count()
|
||||
member_count = Member.objects.count()
|
||||
team_count = Team.objects.count()
|
||||
|
||||
print(f" 削除対象: Entry({entry_count}件), Member({member_count}件), Team({team_count}件)")
|
||||
|
||||
Entry.objects.all().delete()
|
||||
Member.objects.all().delete()
|
||||
Team.objects.all().delete()
|
||||
|
||||
print(" ✅ 既存データクリア完了")
|
||||
|
||||
print("\\n2. チームデータ移行を実行中...")
|
||||
result = subprocess.run([
|
||||
'python', 'migrate_rog_team_enhanced.py'
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(" ✅ チーム移行完了")
|
||||
else:
|
||||
print(f" ❌ チーム移行エラー: {result.stderr}")
|
||||
|
||||
print("\\n3. エントリーデータ移行を実行中...")
|
||||
result = subprocess.run([
|
||||
'python', 'migrate_rog_entry_enhanced.py'
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(" ✅ エントリー移行完了")
|
||||
else:
|
||||
print(f" ❌ エントリー移行エラー: {result.stderr}")
|
||||
|
||||
print("\\n4. 移行結果確認...")
|
||||
from rog.models import NewEvent2
|
||||
|
||||
team_count = Team.objects.count()
|
||||
entry_count = Entry.objects.count()
|
||||
|
||||
print(f" Team: {team_count}件")
|
||||
print(f" Entry: {entry_count}件")
|
||||
|
||||
# FC岐阜イベントのエントリー確認
|
||||
fc_event = NewEvent2.objects.filter(event_name__icontains='FC岐阜').first()
|
||||
if fc_event:
|
||||
fc_entries = Entry.objects.filter(event=fc_event)
|
||||
print(f" FC岐阜イベントエントリー: {fc_entries.count()}件")
|
||||
|
||||
if fc_entries.exists():
|
||||
print(" ✅ ゼッケン番号表示問題が解決されました!")
|
||||
for entry in fc_entries[:3]:
|
||||
print(f" ゼッケン{entry.zekken_number}: {entry.team.team_name}")
|
||||
else:
|
||||
print(" ⚠️ FC岐阜にエントリーがありません")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ エラーが発生しました: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user