Supabase 有一件特别对工程团队胃口的事:
它鼓励你认真对待 SQL-first 和 migration。
这意味着:
- 表结构变更应该版本化
- schema 演进要可追踪
- 团队协作不能只靠 Dashboard 点操作
- 本地开发、预发、生产应该有一致的变更路径
一个 migration 片段示例:
create table public.tasks (
id bigint generated always as identity primary key,
user_id uuid not null references auth.users(id) on delete cascade,
title text not null,
done boolean not null default false,
created_at timestamptz not null default now()
);
alter table public.tasks enable row level security;
create policy "Users can manage their own tasks"
on public.tasks
for all
to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);这件事的工程意义非常大:
不是码头管理员今天手动多修一个仓位
明天另一个人再手动挪个闸门
而是所有港口扩建都有正式施工蓝图所以 Supabase 的成熟用法,绝不是只会在控制台建表。
真正顺手的团队一定会逐渐走向:
- SQL migration
- CLI
- 环境同步
- 审核式 schema 变更