Skip to main content
CodeRocket can automatically execute SQL migrations directly from the interface using your Supabase integration.

🚀 How It Works

When the AI generates a database migration:
  1. A blue alert appears with migration details (tables, RLS policies)
  2. Click “Run Migration” button
  3. The SQL is executed directly on your Supabase database ✅
  4. Your tables are ready to use immediately!
No setup required - Just make sure you have:
  • ✅ Supabase integration configured
  • ✅ Access Token and Project ID added to your integration

📝 Configure Access Token & Project ID

For automatic migrations to work, you need your Supabase Access Token and Project ID:

Getting Your Access Token

  1. Go to your Supabase Dashboard
  2. Click on your profile (top right) → Account
  3. Go to Access Tokens tab
  4. Click “Generate new token”
  5. Give it a name (e.g., “CodeRocket Migrations”)
  6. Copy the token (starts with sbp_...)

Getting Your Project ID

  1. Look at your project URL: https://XXXXX.supabase.co
  2. The Project ID is the part before .supabase.co (e.g., abcdefghijklmnop)
  3. Or find it in Supabase Dashboard → Settings → General → Reference ID

Adding to CodeRocket

  1. Go to AccountIntegrations
  2. Edit your Supabase integration (or create a new one)
  3. Paste the Access Token and Project ID
  4. Save
⚠️ Security: The access token is encrypted and stored securely. It’s only used server-side for migrations.

✨ Using Automatic Migrations

Step 1: Enable Supabase Integration

When creating a project, select your Supabase integration from the database dropdown. Or enable it later:
  • Open the sidebar → Integrations tab
  • Toggle ON your Supabase integration

Step 2: Generate with Database Features

Ask the AI to create something with a database:
"Create a todo list app with Supabase"
"Create a blog with posts and comments"
"Create a product catalog with categories"

Step 3: Run the Migration

When the AI generates a migration:
  1. A blue alert appears: “Database Migration Detected”
  2. Review the tables and policies listed
  3. Click “Run Migration”
  4. ✅ Done! Tables are created instantly
Alternative: Click “Copy SQL” if you prefer to run it manually in Supabase SQL Editor.

🔒 Security & Safety

  • Migrations run via Supabase Management API for maximum reliability
  • Access Token required - uses official Supabase API with proper authentication
  • Tokens are encrypted at rest using AES-256
  • Only authenticated users can run migrations on their own projects
  • Authorization check: You must own the chat to run its migrations
  • All connections use HTTPS/TLS encryption

💡 Migration Features

The migration alerts show:
  • 📊 Tables: List of tables being created
  • 🔒 RLS Policies: Number of Row Level Security policies
  • ▶️ Run Migration: Execute migration automatically
  • 📝 View SQL: View the complete migration code
  • 📋 Copy SQL: Copy SQL to clipboard

🐛 Troubleshooting

”Supabase Access Token and Project ID required for migrations”

Solution:
  1. Generate an access token in Supabase Dashboard → Account → Access Tokens
  2. Get your Project ID from your project URL (the part before .supabase.co)
  3. Add both in Account → Integrations → Edit Supabase Integration

”Migration failed: [error message]”

Common causes:
  • Table already exists → Safe to ignore if intentional
  • Permission issues → Check your access token is valid and has correct permissions
  • Invalid Project ID → Verify the Project ID matches your project URL
  • Connection issues → Verify your Supabase project is online
  • SQL syntax error → Review the SQL code and report to AI
Fallback: Copy the SQL and run it manually in Supabase SQL Editor

Connection timeout

If migration takes too long:
  • The database might be slow to respond
  • Try running the SQL manually in Supabase Dashboard
  • Check your Supabase project status

🎯 Best Practices

Review before running: Check the tables and policies list ✅ Access Token: Keep it secure, never share it, regenerate if compromised ✅ Test in development: Use a development Supabase project first ✅ Backup important data: Migrations can’t be automatically rolled back ✅ Manual option: You can always copy and run SQL manually for safety ✅ Token management: You can revoke and generate new tokens anytime in Supabase Dashboard