一键导入
supabase-migrations
Use when creating database migrations or modifying schema
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when creating database migrations or modifying schema
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when deploying Cloudflare Workers, managing R2 storage, or working with Cloudflare infrastructure
Use when working with ANTD components, theme tokens, icons, forms, or feedback components (message/notification/modal)
Use when adding, referencing, or serving static assets (images, fonts, videos, 3D models) through the R2 CDN pipeline with type-safe imports
Use when writing or reviewing JavaScript/TypeScript code for style patterns like concise arrows, inline handlers, expression formatting, or when tempted to use eslint-disable
Use when working with environment variables in frontend code
Use when creating or modifying keyboard shortcuts/hotkeys in frontend code
基于 SOC 职业分类
| name | supabase-migrations |
| description | Use when creating database migrations or modifying schema |
Guidelines for creating and managing database migrations.
database.types.ts - auto-generatedpnpm sb:dev:types after ANY schema changepnpm sb:dev:push or pnpm sb:dev:reset before productionPattern: YYYYMMDDHHMMSS_descriptive_name.sql
Examples: 20251106183429_add_projects_table.sql
| Method | Command | Best For |
|---|---|---|
| Direct SQL | pnpm sb:dev:new my_feature | New tables, functions, triggers |
| Studio UI Diff | pnpm sb:dev:diff my_feature | Column changes, visual design |
# 1. Create migration
pnpm sb:dev:new add_my_feature # OR pnpm sb:dev:diff add_my_feature
# 2. Write SQL (see template below)
# 3. Apply locally
pnpm sb:dev:push
# 4. Generate TypeScript types
pnpm sb:dev:types
# 5. Test application
pnpm dev
# 6. Push to production (after full verification)
pnpm sb:dev:reset # Verify from scratch first
pnpm sb:prod:push
-- ============================================
-- [FEATURE NAME]
-- ============================================
-- PHASE 1: CREATE TABLE
CREATE TABLE public.my_table (
id TEXT PRIMARY KEY DEFAULT generate_id('pre'),
organization_id TEXT NOT NULL REFERENCES public.organizations(id) ON DELETE CASCADE,
name TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX idx_my_table_org ON public.my_table(organization_id);
-- PHASE 2: ENABLE RLS
ALTER TABLE public.my_table ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Organization members can view"
ON public.my_table FOR SELECT TO authenticated
USING (EXISTS (
SELECT 1 FROM public.organization_members
WHERE organization_members.organization_id = my_table.organization_id
AND organization_members.user_id = (SELECT auth.uid())
));
-- PHASE 3: REALTIME (if org-scoped)
-- Add CASE in get_organization_id_for_change() + attach trigger
supabase-schema-design)pnpm sb:dev:types| Command | Purpose |
|---|---|
pnpm sb:dev:start | Start local Supabase |
pnpm sb:dev:push | Apply migrations (preserves data) |
pnpm sb:dev:reset | Reset DB, re-run all migrations |
pnpm sb:dev:types | Generate TypeScript types |
pnpm sb:dev:new <name> | Create empty migration |
pnpm sb:dev:diff <name> | Generate from UI changes |
pnpm sb:prod:push | Push to production |
sb:dev:push: Day-to-day development (preserves test data)sb:dev:reset: Before production deployment, corrupted state, full verificationcd spark/frontend/my-vite-app && supabase db lint
Fix 0003_auth_rls_initplan, 0006_multiple_permissive_policies, 0009_duplicate_index warnings before deploying.