Agent Skills
返回列表
💻

Supabase 本地开发与迁移

开发编程 更新于 2026.08.29

将以下提示词粘贴到你的 AI 对话框中:

请根据 https://skillhub.cn/install/skillhub.md,安装 @user_3c6cb52e/supabase-cli-local-development-database-migrations。

技能介绍

要解决的问题

当你把 Supabase 当作生产后端时,开发者通常需要把数据库变更、生成类型和边缘函数纳入同一条可重复的流程:本地改 schema 要先验证,提测前要能生成 migration,CI 里还要能安全执行迁移。如果只靠网页手动操作,容易产生环境漂移、变更记录不一致、团队协作时“我这能跑”的问题。

这个技能提供什么

它围绕上游 supabase CLI 的使用方式,把 Supabase 项目放在终端和 CI 中管理,核心能力包括:

  • 本地开发:启动并维护一个本地 Supabase 项目,让数据库、认证、边缘函数在本地形成可迭代的开发闭环。
  • 数据库迁移:将 migration 当作代码资产维护,在本地与流水线中执行一致的迁移路径。
  • 类型生成:基于数据库结构产出类型,减少手写类型带来的不一致。
  • 边缘函数:在命令行侧对 edge functions 进行与项目结构一致的管理。

典型工作流是:在本地项目中修改 schema 与函数,验证行为;把变更落成 migration;在 CI 中用同一命令路径执行迁移与校验,让“变更”可追溯、可回滚、可复盘。

适用边界与注意点

它适合需要在终端或 CI 中标准化 Supabase 工作流的团队,尤其是希望把迁移和类型纳入工程实践的人。上游要求环境中具备 Go 与 Node.js 运行基础;如果你使用 Bun 且版本低于 v1.0.17,在执行 bun add -D supabase 前需要先把 supabase 加入 trusted dependencies。此外,命令可用性与细节以官方文档为准,复杂权限、部署策略与回滚方案仍需要结合项目约定进行审查。

文档参考:https://supabase.com/docs/reference/cli/about。

Summary

This skill is a documentation-driven guide for using the Supabase CLI in day-to-day development and CI. It helps you keep database changes reviewable, generate types from the database, and manage edge functions through command-line workflows.

Workflows it covers

Key steps include starting a local Supabase project for iterative work, turning schema changes into migrations, generating types from the database, and handling edge functions through the CLI.

Boundaries and caveats

It targets developers who want a repeatable terminal/CI workflow for Supabase. The upstream toolchain requires Go and Node.js. If you use Bun versions below v1.0.17, add supabase as a trusted dependency before running bun add -D supabase. For the full command surface and behavior details, rely on the official docs.

Docs: https://supabase.com/docs/reference/cli/about。

使用场景

  • 本地开发时需要快速修改数据库schema并生成迁移脚本
  • 在CI流水线中需要自动执行数据库迁移并生成类型定义
  • 在团队协作场景中需要统一管理数据库迁移版本
  • 为前端项目生成TypeScript类型以便安全访问数据库

适合人员

  • 后端开发者需要管理数据库迁移和类型
  • 全栈开发者需要统一的本地开发体验
  • DevOps工程师需要将迁移纳入CI流程
  • 前端开发者需要类型安全的数据库访问