create-supabase-migration.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Create Supabase Migration ## Command Prompt Generate a Supabase migration file based on the following schema requirements: **Instructions**:1. Create a new migration file in `supabase/migrations/`2. Use timestamp naming: `YYYYMMDDHHMMSS_description.sql`3. Include table creation with all columns and types4. Add proper constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK)5. Create indexes for performance6. Enable Row Level Security (RLS)7. Create RLS policies (SELECT, INSERT, UPDATE, DELETE)8. Add triggers for updated_at timestamps9. Create helper functions if needed10. Include comments explaining complex logic11. Add rollback section at the bottom (commented out) **Standard Patterns**: ```sql-- Create tableCREATE TABLE table_name ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE, created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW()); -- Create indexesCREATE INDEX idx_table_name_user_id ON table_name(user_id); -- Enable RLSALTER TABLE table_name ENABLE ROW LEVEL SECURITY; -- Create policiesCREATE POLICY "Users can view own records" ON table_name FOR SELECT USING (auth.uid() = user_id); -- Create triggerCREATE TRIGGER update_table_name_updated_at BEFORE UPDATE ON table_name FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();``` **Output Requirements**:- Complete SQL migration file- All necessary policies for security- Proper foreign key relationships- Optimized indexes- Documentation comments Generate the complete migration ready to run with `supabase db push`.
/create-supabase-migrationMarkdown