// Database schema RAG system. Activates when working with database tables, migrations, queries, or schema changes.
| name | db-schema |
| description | Database schema RAG system. Activates when working with database tables, migrations, queries, or schema changes. |
| allowed-tools | Read, Grep |
You have access to database schema in ai/schema.jsonl with index in ai/schema_index.json.
The schema file contains ALL tables. Always use the index first.
From user request, identify table names:
ops.tasks, hr.employeespublic.users or hr.employeesRead: ai/schema_index.json
Find candidate table IDs by matching:
table:ops.tasksFrom ai/schema.jsonl, load:
fks and refs_in (optional)Use line-range references from index (refs field):
Read: supabase/reference_schema.sql:780-845
ai/schema_index.json:
{
"table:public.users": {
"keywords": ["user", "employee", "staff"],
"refs": "supabase/reference_schema.sql:100-150",
"fks": ["table:public.departments"],
"refs_in": ["table:ops.tasks"]
}
}
Each line in ai/schema.jsonl:
{
"id": "table:schema.table_name",
"type": "table",
"schema": "schema_name",
"name": "table_name",
"columns": [...],
"fks": [...],
"refs_in": [...]
}
Tables cards and time_logs must NOT have FK constraints:
LEFT JOIN in queriesAll new tables must have:
ALTER TABLE schema.table ENABLE ROW LEVEL SECURITY;
CREATE POLICY "policy_name" ON schema.table ...;
Output format for new migrations:
-- Migration: descriptive_name
-- File: supabase/migrations/YYYYMMDDHHMMSS_name.sql
CREATE TABLE ...;
COMMENT ON TABLE ...;
ALTER TABLE ... ENABLE ROW LEVEL SECURITY;
CREATE POLICY ...;
ai/schema_index.json โ Table index (read first)ai/schema.jsonl โ Detailed schema (read selectively)supabase/reference_schema.sql โ Full SQL schemaai/schema_overrides.json โ Manual descriptionstypes/database.types.ts โ Generated TypeScript types