AgentSkillsCN

supabase-database

编写 Supabase 数据库迁移、函数、RLS 策略以及 SQL 的规范指南。适用于创建或修改数据库表结构、编写迁移脚本、创建 Postgres 函数,或设置行级安全策略时使用。

SKILL.md
--- frontmatter
name: supabase-database
description: Guidelines for writing Supabase database migrations, functions, RLS policies, and SQL. Use when creating or modifying database schemas, writing migrations, creating Postgres functions, or setting up Row Level Security policies.

Supabase Database Guidelines

Expert guidance for Postgres database work in a Supabase environment.

Reference Files

TopicReference
Creating migrationsreferences/migrations.md
Database functionsreferences/functions.md
Row Level Security policiesreferences/rls-policies.md
SQL style guidereferences/sql-style-guide.md

Quick Rules

  • Write all SQL in lowercase
  • Always enable RLS on new tables
  • Separate RLS policies per operation (select/insert/update/delete) and per role (anon/authenticated)
  • Migration files: YYYYMMDDHHmmss_short_description.sql in supabase/migrations/
  • Functions default to SECURITY INVOKER with set search_path = ''
  • Use fully qualified names (e.g., public.table_name) in functions