fix(manual-ledger): harden schema init race and sanitize error responses

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-09 11:38:32 +00:00
committed by GitHub
co-authored by genichin
parent 78e347703e
commit a36b451a3d
5 changed files with 103 additions and 4 deletions
+2
View File
@@ -206,6 +206,7 @@ class PostgresPortfolioRepository:
def ensure_schema(self) -> None:
conn = self._connect()
with conn.cursor() as cur:
cur.execute("SELECT pg_advisory_lock(hashtext('portfoliohub.ensure_schema.v1'))")
cur.execute(
"""
CREATE TABLE IF NOT EXISTS users (
@@ -507,6 +508,7 @@ class PostgresPortfolioRepository:
SELECT create_hypertable('portfolio_ledger', 'recorded_at', if_not_exists => TRUE)
"""
)
cur.execute("SELECT pg_advisory_unlock(hashtext('portfoliohub.ensure_schema.v1'))")
@staticmethod
def _row_to_user(row: Any) -> User: