Skip to content

fix: self-heal DB schema on first connection for standalone scripts - #627

Open
essentialbit wants to merge 2 commits into
mainfrom
fix/lazy-schema-init-rebase-20260822
Open

fix: self-heal DB schema on first connection for standalone scripts#627
essentialbit wants to merge 2 commits into
mainfrom
fix/lazy-schema-init-rebase-20260822

Conversation

@essentialbit

Copy link
Copy Markdown
Owner

Summary

Supersedes #510 — please close that one once this merges (same intent, rebased onto current schema).

Test plan

  • from main import app still imports cleanly
  • ast.parse() clean
  • Verified against a scratch DB copy (never the live DB): dropped provider_health, confirmed a fresh-process get_conn() call self-heals it via lazy init_db()
  • Verified a second get_conn() call in the same process doesn't re-run init_db() (no duplicate admin-seed output, no recursion)

🤖 Generated with Claude Code

Rebase of PR #510 onto current main (that branch predated the tax_lots
schema merge and had gone CONFLICTING as a result — not a real edit
collision, just staleness). Re-applies the original two hunks verbatim:
memory_store.init_db() only ran from main.py's startup, so any script
importing memory_store directly (sensor cycles, verification scripts)
crashed on tables/columns added by a migration since the live DB was
last initialized. get_conn() now lazily runs init_db() once per process
before the first real connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant