fix: self-heal DB schema on first connection for standalone scripts - #627
Open
essentialbit wants to merge 2 commits into
Open
fix: self-heal DB schema on first connection for standalone scripts#627essentialbit wants to merge 2 commits into
essentialbit wants to merge 2 commits into
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main— that branch predated thetax_lotsschema (units 4.1/4.2, PR Phase 4 Unit 4.1: tax_lots schema + additive migration + backfill #614/Phase 4 Unit 4.2: lot-aware backend CRUD + aggregation #615) and had drifted intoCONFLICTING, not a real edit collision, just staleness (confirmed via diff review: every non-lazy-init hunk in the old diff was main's newer schema, not an intentional removal).memory_store.init_db()only ran frommain.py's startup, so any script that importsmemory_storedirectly (sensor cycles, verification scripts) crashed on tables/columns added by a migration since the live DB was last initialized.get_conn()now lazily runsinit_db()once per process before the first real connection.init_db()itself usesget_conn(), so the_schema_readyflag is set before calling it to avoid recursion — safe sinceinit_db()'s own migrations are allCREATE TABLE IF NOT EXISTS/ try-except-guardedALTER TABLE.Supersedes #510 — please close that one once this merges (same intent, rebased onto current schema).
Test plan
from main import appstill imports cleanlyast.parse()cleanprovider_health, confirmed a fresh-processget_conn()call self-heals it via lazyinit_db()get_conn()call in the same process doesn't re-runinit_db()(no duplicate admin-seed output, no recursion)🤖 Generated with Claude Code