Note: This is mock/placeholder content for demonstration purposes.
Database migrations allow you to version control your database schema changes and apply them consistently across environments.
To create a new migration, use the following command:
pnpm --filter web supabase:db:diff
This will generate a new migration file in the apps/web/supabase/migrations directory based on the differences between your local database and the schema files.
To apply migrations to your local database:
pnpm --filter web supabase migrations up
-- Create a new table CREATE TABLE tasks ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), account_id UUID NOT NULL REFERENCES accounts(id) ON DELETE CASCADE, title TEXT NOT NULL, completed BOOLEAN DEFAULT false, created_at TIMESTAMPTZ DEFAULT now() ); -- Add RLS ALTER TABLE tasks ENABLE ROW LEVEL SECURITY; -- Create policies CREATE POLICY "Users can view their account tasks" ON tasks FOR SELECT USING (account_id IN (SELECT get_user_accounts(auth.uid())));
To completely reset your local database with the latest schema:
pnpm supabase:web:reset
This will drop all tables and reapply all migrations from scratch.