refactor: Move maintenance scripts to a dedicated maintenance_scripts/ directory.

This commit is contained in:
kiyreload27
2026-01-05 22:58:22 +00:00
parent 9cbfb29477
commit 40047ee145
19 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,37 @@
import sqlite3
import os
DB_PATH = os.path.join("database", "umamusume.db")
def repair_db():
if not os.path.exists(DB_PATH):
return
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
print("Repairing database...")
# 1. Remove all orphans
cur.execute("DELETE FROM support_effects WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned effects")
cur.execute("DELETE FROM support_hints WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned hints")
cur.execute("DELETE FROM event_skills WHERE event_id NOT IN (SELECT event_id FROM support_events)")
print(f"Removed {cur.rowcount} orphaned event skills")
cur.execute("DELETE FROM support_events WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
print(f"Removed {cur.rowcount} orphaned events")
# 2. Cleanup owned_cards and deck_slots
cur.execute("DELETE FROM owned_cards WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
cur.execute("DELETE FROM deck_slots WHERE card_id NOT IN (SELECT card_id FROM support_cards)")
conn.commit()
conn.close()
print("Repair complete.")
if __name__ == "__main__":
repair_db()