Workflow chuẩn khi làm việc với Supabase (DDL/migrations, query/debug, RLS policies) cho repo này.
apply_migration.execute_sql.create_branch cho development isolation.get_advisors sau khi thay đổi schema.apps/web/src/services/*-service.ts@/lib/supabase/server (thường await createClient()).@/lib/supabase/client (dùng trong Client Components).apps/web/supabase/migrations/** (theo thứ tự timestamp).-- Tạo bảng mới
CREATE TABLE IF NOT EXISTS public.posts (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
title TEXT NOT NULL,
slug TEXT UNIQUE NOT NULL,
content TEXT,
published_at TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Enable RLS
ALTER TABLE public.posts ENABLE ROW LEVEL SECURITY;
-- Tạo policy cho authenticated users
CREATE POLICY "Users can insert their own posts"
ON public.posts
FOR INSERT
WITH CHECK (auth.uid() = user_id);
auth.uid() để check ownership.execute_sql trước khi deploy.# Tạo development branch
supabase branch create feature-new-table
# Sau khi done, merge về main
supabase branch merge <branch_id>
get_advisors (security/performance) sau khi thay đổi schema.