Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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:

  1. Go to Settings → Database
  2. Click "Download backup"
  3. Save the .sql file

Or via CLI:

# Using Supabase CLI
supabase db dump -f backup.sql

2. Create Postbase Project

# Create cloud project
postbase cloud projects create myapp
 
# Provision database
postbase cloud provision production -p myapp

3. Import Database

# Get connection string
POSTBASE_URL=$(postbase cloud url production -p myapp)
 
# Import backup
psql "$POSTBASE_URL" < backup.sql

4. 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

MethodStatus
.from()
.select()
.insert()
.update()
.delete()
.eq()
.neq()
.gt(), .gte(), .lt(), .lte()
.like(), .ilike()
.in()
.is()
.order()
.limit()
.single()
.maybeSingle()
.rpc()

Different Approach

FeatureSupabasePostbase
RealtimeWebSocketLISTEN/NOTIFY
AuthSupabase AuthBring your own
StorageSupabase StorageBring your own

Extension Compatibility

Postbase includes the same PostgreSQL extensions as Supabase:

ExtensionStatus
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:

  1. Auth.js (NextAuth) - OAuth, email, credentials
  2. Lucia - Session-based auth
  3. Clerk - Managed auth service
  4. 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:

  1. Cloudflare R2 - S3-compatible, cheap
  2. AWS S3 - Industry standard
  3. 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=disable

Testing Migration

  1. Local testing first:

    postbase start
    postbase db create myapp_test
    psql "postgresql://localhost:5432/myapp_test" < backup.sql
  2. Run your test suite
  3. Deploy to staging:

    postbase cloud provision staging -p myapp
  4. Production cutover

Rollback Plan

Keep Supabase running during migration:

  1. Enable read-only mode on Supabase
  2. Export final backup
  3. Import to Postbase
  4. Switch traffic
  5. Monitor for issues
  6. Decommission Supabase after validation period