feat: add Postgres/Supabase backend for memory store#40
Open
Siddhant-K-code wants to merge 2 commits intomainfrom
Open
feat: add Postgres/Supabase backend for memory store#40Siddhant-K-code wants to merge 2 commits intomainfrom
Siddhant-K-code wants to merge 2 commits intomainfrom
Conversation
Adds PostgresStore alongside the existing SQLiteStore, both implementing
the memory.Store interface. This allows persistent memory storage in
Supabase instead of ephemeral SQLite on Render.
Changes:
- pkg/memory/postgres.go: full Store implementation using pgx driver
- pkg/memory/postgres_migration.sql: schema for Supabase SQL editor
- cmd/api.go, cmd/mcp.go: new --memory-backend and --memory-dsn flags
- cmd/api_memory.go: MemoryAPI now uses Store interface, not SQLiteStore
- cmd/memory.go: memoryStoreFromConfig supports 'sqlite' and 'postgres'
Usage:
distill api --memory --memory-backend postgres \
--memory-dsn 'postgres://user:pass@host:5432/db?sslmode=require'
Co-authored-by: Ona <no-reply@ona.com>
- Remove dead argIdx increment (ineffectual assignment) - README: add postgres backend usage, config examples, DATABASE_URL env var - CHANGELOG: add unreleased section for postgres backend - FAQ: mention postgres/supabase option in memory description Co-authored-by: Ona <no-reply@ona.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Memories stored on Render's SQLite are lost on every redeploy (ephemeral filesystem). This adds a Postgres backend so memories persist in Supabase.
Changes
pkg/memory/postgres.go— FullStoreinterface implementation usingpgxdriver. Same semantics as SQLiteStore: write-time dedup, tag filtering, relevance+recency scoring, touch-on-recall.pkg/memory/postgres_migration.sql— Schema to run in Supabase SQL Editor (memories + memory_tags tables with indexes).cmd/api.go— New--memory-backend(sqlite|postgres) and--memory-dsnflags.cmd/mcp.go— Same new flags for MCP server.cmd/api_memory.go—MemoryAPI.storechanged from*SQLiteStoretoStoreinterface.cmd/memory.go—memoryStoreFromConfignow routes to SQLite or Postgres based on backend flag.Usage
Render deployment
After merging, update the Render start command to:
And add
DATABASE_URLenv var with the Supabase connection string.Tests
All 11 existing memory tests pass. Postgres store implements the same interface — no Postgres-specific tests needed (would require a live database in CI).