Import ClientFlow production v4928.1.5.132.4
This commit is contained in:
15
app/db.py
15
app/db.py
@@ -149,6 +149,8 @@ def ensure_core_schema() -> None:
|
||||
"ALTER TABLE tasks ADD COLUMN IF NOT EXISTS done_by TEXT",
|
||||
"ALTER TABLE tasks ADD COLUMN IF NOT EXISTS metadata JSONB NOT NULL DEFAULT '{}'::jsonb",
|
||||
"ALTER TABLE tasks ADD COLUMN IF NOT EXISTS idempotency_key TEXT",
|
||||
"ALTER TABLE tasks ADD COLUMN IF NOT EXISTS priority TEXT NOT NULL DEFAULT 'normal'",
|
||||
"ALTER TABLE tasks ADD COLUMN IF NOT EXISTS assigned_to TEXT",
|
||||
]:
|
||||
conn.execute(text(statement))
|
||||
|
||||
@@ -237,7 +239,16 @@ def ensure_core_schema() -> None:
|
||||
)
|
||||
"""))
|
||||
|
||||
# Older ClientFlow installs may already have integration_outbox created
|
||||
# without newer operational columns. The outbox worker selects/updates
|
||||
# these columns directly, so guarantee them on every schema init.
|
||||
for statement in [
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS business_event_id UUID",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS retry_count INTEGER NOT NULL DEFAULT 0",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS idempotency_key TEXT",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS last_error TEXT",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT now()",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS sent_at TIMESTAMPTZ",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS locked_at TIMESTAMPTZ",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS lock_owner TEXT",
|
||||
"ALTER TABLE integration_outbox ADD COLUMN IF NOT EXISTS ignored_at TIMESTAMPTZ",
|
||||
@@ -310,14 +321,18 @@ def init_db() -> None:
|
||||
from app.operation_service import ensure_operation_schema
|
||||
from app.commercial_service import ensure_commercial_schema
|
||||
from app.communication_service import ensure_communication_schema
|
||||
from app.reply_assistant_service import ensure_reply_assistant_schema
|
||||
from app.reconciliation_service import ensure_reconciliation_schema
|
||||
from app.revenue_forecast_service import ensure_revenue_forecast_schema
|
||||
|
||||
ensure_opportunity_schema()
|
||||
ensure_product_schema()
|
||||
ensure_operation_schema()
|
||||
ensure_commercial_schema()
|
||||
ensure_communication_schema()
|
||||
ensure_reply_assistant_schema()
|
||||
ensure_reconciliation_schema()
|
||||
ensure_revenue_forecast_schema()
|
||||
except Exception as exc:
|
||||
print(f"ClientFlow schema init failed: {exc}", flush=True)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user