feat: Implement database update/sync from seed, add schema migrations, and introduce deck skills view.

This commit is contained in:
kiyreload27
2025-12-31 23:18:32 +00:00
parent a2ac99e8b6
commit 040f8396dd
4 changed files with 37 additions and 11 deletions

Binary file not shown.

View File

@@ -75,10 +75,41 @@ def get_conn():
# Check for updates and migrate if needed (only once per session) # Check for updates and migrate if needed (only once per session)
if not _updates_checked: if not _updates_checked:
_updates_checked = True _updates_checked = True
run_migrations()
check_for_updates() check_for_updates()
return sqlite3.connect(DB_PATH) return sqlite3.connect(DB_PATH)
def run_migrations():
"""Ensure database schema is up to date by adding missing columns"""
print("Checking for database migrations...")
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
# 1. Add is_gold to event_skills
try:
cur.execute("ALTER TABLE event_skills ADD COLUMN is_gold INTEGER DEFAULT 0")
print("Added is_gold column to event_skills")
except sqlite3.OperationalError:
pass # Column already exists
# 2. Add is_or to event_skills
try:
cur.execute("ALTER TABLE event_skills ADD COLUMN is_or INTEGER DEFAULT 0")
print("Added is_or column to event_skills")
except sqlite3.OperationalError:
pass # Column already exists
# 3. Add image_path to support_cards
try:
cur.execute("ALTER TABLE support_cards ADD COLUMN image_path TEXT")
print("Added image_path column to support_cards")
except sqlite3.OperationalError:
pass # Column already exists
conn.commit()
conn.close()
def check_for_updates(): def check_for_updates():
"""Check if database version matches app version, sync if outdated""" """Check if database version matches app version, sync if outdated"""
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
@@ -299,15 +330,8 @@ def init_database():
) )
""") """)
# Migration: Add columns to event_skills if they don't exist # Run migrations to ensure all columns exist
try: run_migrations()
cur.execute("ALTER TABLE event_skills ADD COLUMN is_gold INTEGER DEFAULT 0")
except sqlite3.OperationalError:
pass # Column already exists
try:
cur.execute("ALTER TABLE event_skills ADD COLUMN is_or INTEGER DEFAULT 0")
except sqlite3.OperationalError:
pass # Column already exists
# User tables # User tables
cur.execute(""" cur.execute("""

View File

@@ -161,8 +161,10 @@ class DeckSkillsFrame(ttk.Frame):
display_text = f"{owned_mark}{name}" display_text = f"{owned_mark}{name}"
# Parent row only needs display text and rarity (optional) # Parent row only needs display text and rarity (optional)
iid = self.tree.insert('', tk.END, text=display_text, image=img, open=True, # We remove open=True from insert and set it using item() to avoid Tcl Errors on some systems
iid = self.tree.insert('', tk.END, text=display_text, image=img if img else "",
values=("", rarity, f"{type_icon} {card_type}", "")) values=("", rarity, f"{type_icon} {card_type}", ""))
self.tree.item(iid, open=True)
return iid return iid
def add_skill_row(self, parent_id, skill_name, source, details): def add_skill_row(self, parent_id, skill_name, source, details):

View File

@@ -4,7 +4,7 @@ This file is the single source of truth for the application version.
""" """
# Semantic versioning: MAJOR.MINOR.PATCH # Semantic versioning: MAJOR.MINOR.PATCH
VERSION: str = "13.0.0" VERSION: str = "13.0.2"
# Application metadata # Application metadata
APP_NAME: str = "UmamusumeCardManager" APP_NAME: str = "UmamusumeCardManager"