- 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 upto apply the migration and runnpx supabase gen types typescript --local > src/types/database.types.tsto generate the type file - When creating a new table, it must have columns for
created_atandupdated_atand 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/serverto create supabase client in server components and `createBrow