refactor: extract gumbo schema migration to ArgoCD PreSync job
This commit is contained in:
parent
75c95d6bb1
commit
1bb17e204a
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -4,3 +4,4 @@ resources:
|
|||
- gumbo-externalsecrets.yaml
|
||||
- gumbo-job-template.yaml
|
||||
- static-demo.yaml
|
||||
- gumbo-schema-init.yaml
|
||||
|
|
|
|||
Loading…
Reference in New Issue