diff --git a/agents/gumbo/gumbo/temporal/activities.py b/agents/gumbo/gumbo/temporal/activities.py index c08943f..c4dca01 100644 --- a/agents/gumbo/gumbo/temporal/activities.py +++ b/agents/gumbo/gumbo/temporal/activities.py @@ -23,17 +23,7 @@ async def persist_gumbo_summary(payload: dict[str, Any]) -> None: conn = await psycopg.AsyncConnection.connect(dsn) try: async with conn.cursor() as cur: - await cur.execute( - """ - CREATE TABLE IF NOT EXISTS gumbo_summaries ( - id bigserial PRIMARY KEY, - workflow_id text NOT NULL, - object_key text NOT NULL, - summary text NOT NULL, - created_at timestamptz NOT NULL DEFAULT now() - ); - """ - ) + await cur.execute( """ INSERT INTO gumbo_summaries (workflow_id, object_key, summary) diff --git a/agents/k8s/gumbo-schema-init.yaml b/agents/k8s/gumbo-schema-init.yaml new file mode 100644 index 0000000..2a39bfa --- /dev/null +++ b/agents/k8s/gumbo-schema-init.yaml @@ -0,0 +1,35 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: gumbo-schema-init + namespace: ai-agents-gumbo + annotations: + argocd.argoproj.io/hook: PreSync + argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + restartPolicy: OnFailure + containers: + - name: schema-init + image: postgres:16-alpine + command: + - sh + - -c + - | + psql "$PGURL" -c " + CREATE TABLE IF NOT EXISTS gumbo_summaries ( + id bigserial PRIMARY KEY, + workflow_id text NOT NULL, + object_key text NOT NULL, + summary text NOT NULL, + created_at timestamptz NOT NULL DEFAULT now() + );" + env: + - name: PGURL + valueFrom: + secretKeyRef: + name: gumbo-results-db + key: dsn + - name: PGDATABASE + value: gumbo diff --git a/agents/k8s/kustomization.yaml b/agents/k8s/kustomization.yaml index 21184bd..063e000 100644 --- a/agents/k8s/kustomization.yaml +++ b/agents/k8s/kustomization.yaml @@ -4,3 +4,4 @@ resources: - gumbo-externalsecrets.yaml - gumbo-job-template.yaml - static-demo.yaml + - gumbo-schema-init.yaml