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:
co-authored by
genichin
parent
78e347703e
commit
a36b451a3d
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user