Production-ready database schema patterns for AI applications including chat/conversation schemas, RAG document storage with pgvector, multi-tenant organization models, user management, and AI usage tracking. Use when building AI applications, creating database schemas, setting up chat systems, implementing RAG, designing multi-tenant databases, or when user mentions supabase schemas, chat database, RAG storage, pgvector, embeddings, conversation history, or AI application database.
/plugin marketplace add vanman2024/ai-dev-marketplace/plugin install supabase@ai-dev-marketplaceThis skill is limited to using the following tools:
README.mdexamples/complete-ai-app-schema.mdexamples/indexing-strategy.mdexamples/migration-guide.mdscripts/apply-migration.shscripts/generate-schema.shscripts/seed-data.shscripts/validate-schema.shtemplates/ai-usage-tracking-schema.sqltemplates/chat-schema.sqltemplates/migration-template.sqltemplates/multi-tenant-schema.sqltemplates/rag-schema.sqltemplates/user-management-schema.sqlProduction-ready PostgreSQL/Supabase database schemas optimized for AI applications including chat systems, RAG (Retrieval-Augmented Generation), multi-tenancy, and usage tracking.
Ask the user which schema pattern they need:
Use the generation script:
cd /home/vanman2025/Projects/ai-dev-marketplace/plugins/supabase/skills/schema-patterns
./scripts/generate-schema.sh <pattern-type> <output-file>
Pattern types: chat, rag, multi-tenant, user-management, ai-usage, complete
Before applying, validate the generated schema:
./scripts/validate-schema.sh <schema-file>
This checks for:
Apply the schema to your Supabase project:
./scripts/apply-migration.sh <schema-file> <migration-name>
This creates a timestamped migration file and validates before applying.
For development, generate realistic test data:
./scripts/seed-data.sh <pattern-type>
chat-schema.sql: Complete chat/conversation system with users, conversations, messages, participantsrag-schema.sql: RAG document storage with chunks, embeddings (pgvector), and similarity searchmulti-tenant-schema.sql: Organization-based multi-tenancy with orgs, teams, members, rolesuser-management-schema.sql: Extended user profiles, metadata, preferencesai-usage-tracking-schema.sql: Token usage, API costs, rate limiting, usage analyticsmigration-template.sql: Boilerplate migration structure with version trackingindexes-template.sql: Performance optimization index patternsrls-policies-template.sql: Row Level Security policy patternsAll RAG schemas include:
Organization-based isolation:
Optimized for real-time messaging:
See the examples directory for:
complete-ai-app-schema.md: Full schema combining all patternsmigration-guide.md: Schema evolution and versioningindexing-strategy.md: Performance optimization guide./scripts/generate-schema.sh chat schema.sql
./scripts/validate-schema.sh schema.sql
./scripts/apply-migration.sh schema.sql "initial-chat-schema"
./scripts/seed-data.sh chat
./scripts/generate-schema.sh rag schema.sql
./scripts/validate-schema.sh schema.sql
./scripts/apply-migration.sh schema.sql "add-rag-storage"
./scripts/seed-data.sh rag
./scripts/generate-schema.sh complete schema.sql
./scripts/validate-schema.sh schema.sql
./scripts/apply-migration.sh schema.sql "complete-ai-platform"
pgvector not found: Enable the vector extension in Supabase dashboard (Database > Extensions)
RLS blocks queries: Check RLS policies or temporarily disable for testing (not recommended for production)
Slow similarity search: Ensure HNSW index is created on vector columns with proper operator class
Migration conflicts: Check migration version ordering and resolve conflicts manually
Skill Location: /home/vanman2025/Projects/ai-dev-marketplace/plugins/supabase/skills/schema-patterns/ Version: 1.0.0
Use when working with Payload CMS projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.