Complete Supabase setup for Mem0 OSS including PostgreSQL schema with pgvector for embeddings, memory_relationships tables for graph memory, RLS policies for user/tenant isolation, performance indexes, connection pooling, and backup/migration strategies. Use when setting up Mem0 with Supabase, configuring OSS memory backend, implementing memory persistence, migrating from Platform to OSS, or when user mentions Mem0 Supabase, memory database, pgvector for Mem0, memory isolation, or Mem0 backup.
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/mem0/skills/supabase-integration/SKILL.md -a claude-code --skill supabase-integrationInstallation paths:
.claude/skills/supabase-integration/# Supabase Integration for Mem0 OSS Complete guide for setting up Supabase as the backend for Mem0 Open Source (self-hosted) mode, including PostgreSQL schema with pgvector, RLS policies for security, and production-ready configurations. ## Instructions ### Phase 1: Supabase Project Setup **Prerequisites Check:** 1. Verify Supabase is initialized: ```bash bash scripts/verify-supabase-setup.sh ``` 2. If not initialized, set up Supabase first: - Run `/supabase:init` command - Note down project ID and connection details - Obtain connection string from Supabase dashboard **Environment Configuration:** ```bash # Required environment variables SUPABASE_URL=https://your-project.supabase.co SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_KEY=your-service-key SUPABASE_DB_URL=postgresql://postgres:[password]@db.[project].supabase.co:5432/postgres # Optional: Mem0-specific configs MEM0_EMBEDDING_MODEL=text-embedding-3-small MEM0_VECTOR_DIMENSION=1536 ``` ### Phase 2: Enable pgvector Extension **Enable Extension:** ```bash bash scripts/setup-mem0-pgvector.sh ``` This script: 1. Connects to Supabase database 2. Enables pgvector extension 3. Verifies extension is active 4. Checks PostgreSQL version compatibility (>= 12) **Manual Verification:** ```sql -- Check pgvector is enabled SELECT * FROM pg_extension WHERE extname = 'vector'; -- Test vector operations SELECT '[1,2,3]'::vector; ``` ### Phase 3: Create Memory Tables Schema **Apply Memory Schema:** ```bash bash scripts/apply-mem0-schema.sh ``` This creates three core tables: **1. memories table** (vector storage): - `id` (uuid, primary key) - `user_id` (text, indexed) - User identifier for isolation - `agent_id` (text, indexed, nullable) - Agent identifier - `run_id` (text, indexed, nullable) - Session/conversation identifier - `memory` (text) - Memory content - `hash` (text) - Content hash for deduplication - `metadata` (jsonb) - Flexible metadata storage - `categories` (text[]) - Memory cat