feat: 套装方案对比与导出功能 #32

Merged
hera merged 37 commits from feat/kit-comparison-export into main 2026-04-14 13:32:34 +00:00
Showing only changes of commit 9562cbfe25 - Show all commits

View File

@@ -254,8 +254,13 @@ def init_db():
# Migration: rename oils 西洋蓍草→西洋蓍草石榴籽, 元气→元气焕能
_oil_renames = [("西洋蓍草", "西洋蓍草石榴籽"), ("元气", "元气焕能")]
for old_name, new_name in _oil_renames:
exists = c.execute("SELECT 1 FROM oils WHERE name = ?", (old_name,)).fetchone()
if exists:
old_exists = c.execute("SELECT 1 FROM oils WHERE name = ?", (old_name,)).fetchone()
new_exists = c.execute("SELECT 1 FROM oils WHERE name = ?", (new_name,)).fetchone()
if old_exists and new_exists:
# Both exist: delete old, update recipe references to new
c.execute("DELETE FROM oils WHERE name = ?", (old_name,))
c.execute("UPDATE recipe_ingredients SET oil_name = ? WHERE oil_name = ?", (new_name, old_name))
elif old_exists:
c.execute("UPDATE oils SET name = ? WHERE name = ?", (new_name, old_name))
c.execute("UPDATE recipe_ingredients SET oil_name = ? WHERE oil_name = ?", (new_name, old_name))