feat(insta-lab): db migration — trending_keywords.source + account_preferences + CRUD

- Idempotent ALTER TABLE adds source column (default 'manual') + idx_tk_source index
- New account_preferences table seeded with economy/psychology/celebrity at weight=1.0
- add_trending_keyword now accepts optional source param
- New helpers: add_external_trend, list_trends, get_preferences, upsert_preferences
- test_db updated: six→seven tables; test_preferences_crud.py (7 new tests, all pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 17:44:01 +09:00
parent 002c0893f8
commit b3982c8f72
3 changed files with 155 additions and 3 deletions

View File

@@ -24,7 +24,7 @@ def tmp_db(monkeypatch):
pass
def test_init_db_creates_six_tables(tmp_db):
def test_init_db_creates_seven_tables(tmp_db):
with db_module._conn() as conn:
rows = conn.execute(
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
@@ -33,6 +33,7 @@ def test_init_db_creates_six_tables(tmp_db):
assert names == sorted([
"news_articles", "trending_keywords", "card_slates",
"card_assets", "generation_tasks", "prompt_templates",
"account_preferences",
])