4.6 KiB
4.6 KiB
Supabase Migration Summary
✅ What Was Created
1. Documentation
SUPABASE_SETUP.md- Complete setup guide with step-by-step instructionssupabase/schema.sql- Full database schema with tables, indexes, RLS policies, and functions
2. Migration Script
scripts/migrate-to-supabase.ts- TypeScript script to migrate all data from SQLite to Supabase
3. New Supabase Client Code
src/lib/supabase/client.ts- Supabase client configurationsrc/lib/supabase/database.types.ts- TypeScript types for database tables
4. Updated Server Modules
src/lib/server/auth.ts- Completely rewritten to use Supabase instead of SQLitesrc/lib/server/taskDb.ts- Completely rewritten to use Supabase instead of SQLite
5. Environment Template
.env.local.example- Template for required environment variables
📊 Your Current Data
- 2 users → Will be migrated
- 19 tasks → Will be migrated
- 3 projects → Will be migrated
- 3 sprints → Will be migrated
🚀 Next Steps (In Order)
Step 1: Create Supabase Project
- Go to https://supabase.com/dashboard
- Click "New Project"
- Fill in details:
- Name:
gantt-board(or your choice) - Database Password: Generate a strong password
- Region: Choose closest to you (e.g.,
us-east-1)
- Name:
- Wait for creation (~2 minutes)
Step 2: Get Credentials
- Go to Project Settings → API
- Copy:
- Project URL
anonpublic keyservice_rolesecret key
Step 3: Set Up Environment Variables
cd /Users/mattbruce/Documents/Projects/OpenClaw/Web/gantt-board
cp .env.local.example .env.local
Edit .env.local and fill in your actual Supabase credentials:
NEXT_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key-here
Step 4: Run the Database Schema
- Go to Supabase Dashboard → SQL Editor
- Click "New Query"
- Copy contents of
supabase/schema.sql - Click "Run"
Step 5: Migrate Your Data
cd /Users/mattbruce/Documents/Projects/OpenClaw/Web/gantt-board
npx tsx scripts/migrate-to-supabase.ts
You should see output like:
🚀 Starting SQLite → Supabase migration
✅ Connected to Supabase
📦 Migrating users...
✓ user@example.com
✅ Migrated 2 users
📦 Migrating sessions...
✅ Migrated X sessions
...
✅ Migration Complete!
Step 6: Test Locally
npm run dev
Test all functionality:
- Login/logout
- Create/edit tasks
- Create/edit projects
- Create/edit sprints
Step 7: Deploy to Vercel
- Push code to git (the Supabase code is already in place)
- Add environment variables in Vercel dashboard:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY
- Deploy!
🔐 Security Notes
- Never commit
.env.local- It's already in.gitignore - Service Role Key - Only used server-side, never expose to browser
- Row Level Security - Enabled on all tables with appropriate policies
- Password Hashing - Uses same scrypt algorithm as before
📁 Files Modified/Created
New Files:
SUPABASE_SETUP.mdsupabase/schema.sqlscripts/migrate-to-supabase.tssrc/lib/supabase/client.tssrc/lib/supabase/database.types.ts.env.local.example
Modified Files:
package.json- Added@supabase/supabase-jsanddotenvsrc/lib/server/auth.ts- Rewritten for Supabasesrc/lib/server/taskDb.ts- Rewritten for Supabase
🔄 Rollback Plan
If something goes wrong:
- Keep your
data/tasks.dbfile - it's untouched - You can revert the code changes with git:
git checkout src/lib/server/auth.ts src/lib/server/taskDb.ts - Remove Supabase env vars to fall back to SQLite
❓ Troubleshooting
Migration fails with connection error
- Check that your Supabase URL and keys are correct
- Ensure your Supabase project is active (not paused)
Data doesn't appear after migration
- Check the migration script output for errors
- Verify tables were created by checking Supabase Table Editor
Auth issues after migration
- Users will need to log in again (sessions aren't migrated by default)
- Passwords are preserved - same login credentials work
🎉 You're All Set!
Once you complete the steps above, your Gantt Board will be running on Supabase with:
- ✅ Persistent data that survives server restarts
- ✅ Works on Vercel (no file system dependencies)
- ✅ Can scale to multiple servers
- ✅ Real-time capabilities (future enhancement possible)