Migrating from Supabase
Migrate your Supabase project to Postbase.
Overview
Postbase is designed for easy migration from Supabase:
- Same PostgreSQL extensions
- Compatible query API
- Similar project structure
Migration Steps
1. Export Database
From Supabase Dashboard:
- Go to Settings → Database
- Click "Download backup"
- Save the
.sqlfile
Or via CLI:
# Using Supabase CLI
supabase db dump -f backup.sql2. Create Postbase Project
# Create cloud project
postbase cloud projects create myapp
# Provision database
postbase cloud provision production -p myapp3. Import Database
# Get connection string
POSTBASE_URL=$(postbase cloud url production -p myapp)
# Import backup
psql "$POSTBASE_URL" < backup.sql4. Update SDK
Replace Supabase client:
// Before: Supabase
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_KEY!
)
// After: Postbase
import { createClient } from '@postbase/sdk'
import type { Database } from './db/types'
const db = createClient<Database>({
connectionString: process.env.DATABASE_URL!,
})5. Update Queries
Most queries work unchanged:
// Both work the same
const users = await db
.from('users')
.eq('active', true)
.order('created_at', { ascending: false })
.limit(10)
.execute()API Compatibility
Fully Compatible
| Method | Status |
|---|---|
.from() | ✅ |
.select() | ✅ |
.insert() | ✅ |
.update() | ✅ |
.delete() | ✅ |
.eq() | ✅ |
.neq() | ✅ |
.gt(), .gte(), .lt(), .lte() | ✅ |
.like(), .ilike() | ✅ |
.in() | ✅ |
.is() | ✅ |
.order() | ✅ |
.limit() | ✅ |
.single() | ✅ |
.maybeSingle() | ✅ |
.rpc() | ✅ |
Different Approach
| Feature | Supabase | Postbase |
|---|---|---|
| Realtime | WebSocket | LISTEN/NOTIFY |
| Auth | Supabase Auth | Bring your own |
| Storage | Supabase Storage | Bring your own |
Extension Compatibility
Postbase includes the same PostgreSQL extensions as Supabase:
| Extension | Status |
|---|---|
pg_cron | ✅ |
pgvector | ✅ |
PostGIS | ✅ |
uuid-ossp | ✅ |
pgcrypto | ✅ |
pg_stat_statements | ✅ |
Realtime Migration
Supabase Realtime
// Supabase
supabase
.channel('changes')
.on('postgres_changes', { event: 'INSERT', table: 'users' }, handler)
.subscribe()Postbase Realtime
// Postbase (requires trigger setup)
db.channel('users')
.on('INSERT', handler)
.subscribe()See Realtime for setup instructions.
Auth Migration
Postbase doesn't include built-in auth. Options:
- Auth.js (NextAuth) - OAuth, email, credentials
- Lucia - Session-based auth
- Clerk - Managed auth service
- Custom - Roll your own
Database Tables
Keep your existing auth tables or migrate to Auth.js:
-- Your existing users table works
SELECT * FROM auth.users;
-- Or create new schema
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);Storage Migration
Postbase doesn't include object storage. Options:
- Cloudflare R2 - S3-compatible, cheap
- AWS S3 - Industry standard
- MinIO - Self-hosted S3
Migrating Files
# Export from Supabase Storage
supabase storage ls -b bucket-name > files.txt
# Download files
cat files.txt | while read file; do
supabase storage cp "gs://bucket-name/$file" "./$file"
done
# Upload to R2/S3
aws s3 sync ./files s3://new-bucket/Edge Functions → Cloudflare Workers
Supabase Edge Function
// supabase/functions/hello/index.ts
Deno.serve(async (req) => {
return new Response('Hello!')
})Cloudflare Worker
// src/index.ts
export default {
fetch(request: Request) {
return new Response('Hello!')
}
}Environment Variables
Update your environment:
# Before
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_KEY=eyJ...
# After
DATABASE_URL=postgresql://postgres:xxx@xxx.proxy.rlwy.net:12345/railway?sslmode=disableTesting Migration
-
Local testing first:
postbase start postbase db create myapp_test psql "postgresql://localhost:5432/myapp_test" < backup.sql - Run your test suite
-
Deploy to staging:
postbase cloud provision staging -p myapp - Production cutover
Rollback Plan
Keep Supabase running during migration:
- Enable read-only mode on Supabase
- Export final backup
- Import to Postbase
- Switch traffic
- Monitor for issues
- Decommission Supabase after validation period