Migrating from JSON-on-pod to a real database without changing the agent interface.
Context
The agent stored conversation history as a JSON file inside the pod. It worked — until the pod restarted. Any in-flight conversation was gone. Kubernetes is not a filesystem, so the fix was migrating to Postgres, which was already running via CloudNativePG.
The constraint: the agent code couldn't change how it accessed storage. Same interface, swapped backend.
Interface
ConversationStore
The agent used a simple storage interface. The JSON implementation wrote to disk; the Postgres implementation hits a table. Same contract, different driver.
The migration
Schema
CREATE TABLE first, then run CREATE INDEX as a separate statement. If you try to declare an index mid-migration before the table exists in full, Postgres returns a parse error that's easy to misread as a column type issue. Split them — table first, indexes after.Postgres implementation
Lessons