- Use supabase for database queries and schema
- Before performing any database related tasks, make sure to read the database.types.ts first for existing database schema
- Always use migrations to update the database schema, create them using the command
npx supabase migration new <migration-name>
- Afer creating a migration file, run
npx supabase migration up
to apply the migration and runnpx supabase gen types typescript --local > src/types/database.types.ts
to generate the type file - When creating a new table, it must have columns for
created_at
andupdated_at
and the values should be set automatically via triggers usingpublic.handle_created_at()
andpublic.handle_updated_at()
- Always enable Row Level Security (RLS) on newly create tables via
ALTER TABLE <table_name> ENABLE ROW LEVEL SECURITY;
in migration files and add reasonable policies - Always use
await createServerClient()
in the@/utils/supabase/server
to create supabase client in server components andcreateBrowserClient()
in the@/utils/supabase/client
to create supabase client in client components - Always maintain backwards compatibility when generating migrations
Created
March 27, 2025 20:59
-
-
Save yifanzz/78f9116ec381bdee9e079f214ac4ac75 to your computer and use it in GitHub Desktop.
YouTube Episode Supabase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
supabase start | |
supabase migration create <migration_name> | |
supabase migration up | |
supabase db diff -f <migration_name> | |
supabase db reset | |
supabase db dump --data-only --local -f seed.sql | |
supabase db push | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment