Files
metabuilder/txt/SUPABASE_SUPPORT_ADDED_2026-02-06.md
2026-03-09 22:30:41 +00:00

4.8 KiB

Supabase Backend Support Added

Date: 2026-02-06
Status: Complete - Ready for Testing

What Was Added

2 New Supabase Backends

  1. supabase_rest - REST API mode

    • Uses Supabase REST API via HTTP client
    • Authentication via API keys
    • Automatic RLS enforcement
    • Best for: Public APIs, mobile apps
  2. supabase_postgres - Direct PostgreSQL mode

    • Raw PostgreSQL connection to Supabase
    • Full SQL feature set
    • Manual RLS setup
    • Best for: Backend services, ETL

Updated Test Matrix

Total backends now: 8

  • sqlite (memory)
  • sqlite_file
  • postgres (direct)
  • mysql (direct)
  • mongodb (NoSQL)
  • prisma_postgres (ORM)
  • supabase_rest (NEW)
  • supabase_postgres (NEW)

Usage

Quick Test (using hosted Supabase)

# Set credentials
export SUPABASE_URL="https://your-project.supabase.co"
export SUPABASE_KEY="your-anon-key"

# Test REST API mode
python3 dev-container.py test-matrix --backend supabase_rest

# Test Direct PostgreSQL mode
python3 dev-container.py test-matrix --backend supabase_postgres

# Test all backends (including Supabase)
python3 dev-container.py test-matrix

Local Supabase Stack

# Install and start local Supabase
npm install -g supabase
supabase init
supabase start

# Get credentials
supabase status

# Set env vars and test
export SUPABASE_URL="http://localhost:54321"
export SUPABASE_KEY="<key-from-status>"
python3 dev-container.py test-matrix --backend supabase_rest

Configuration

REST API Mode

{
  "adapter": "supabase",
  "database_url": "https://your-project.supabase.co",
  "mode": "production",
  "supabase_mode": "rest",
  "supabase_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Direct PostgreSQL Mode

{
  "adapter": "supabase",
  "database_url": "postgresql://postgres:postgres@db.your-project.supabase.co:5432/postgres",
  "mode": "production",
  "supabase_mode": "postgres"
}

Environment Variables

Added to docker-compose.yml:

  • SUPABASE_URL - Project URL (default: placeholder)
  • SUPABASE_KEY - Anon or service role key
  • SUPABASE_SERVICE_KEY - Service role key (admin access)

Files Modified

  1. test_matrix.py - Added supabase_rest and supabase_postgres backends
  2. docker-compose.yml - Added Supabase environment variables
  3. dev-container.py - Updated choices to include Supabase backends
  4. SUPABASE_TESTING.md - Comprehensive testing guide (NEW)

Features

Multi-Tenant Support

Supabase's Row-Level Security (RLS) provides automatic tenant isolation:

-- Enable RLS
ALTER TABLE users ENABLE ROW LEVEL SECURITY;

-- Create policy
CREATE POLICY tenant_isolation ON users
    USING (tenant_id = current_setting('app.current_tenant')::text);

DBAL automatically sets the tenant context per request.

Authentication

REST API Mode:

  • Anon key: Safe for client apps (limited by RLS)
  • Service role key: Backend only (bypasses RLS)

Direct PostgreSQL Mode:

  • Database credentials
  • Optional SSL/TLS
  • Connection pooling via pgBouncer

Expected Results

🎯 DBAL Multi-Backend Test Matrix
Testing: sqlite, postgres, mysql, mongodb, prisma_postgres, supabase_rest, supabase_postgres

supabase_rest        ✅ PASS (17/17 tests)
supabase_postgres    ✅ PASS (17/17 tests)

Total: 8/8 backends passing

Comparison: REST vs Direct

Feature REST API Direct PostgreSQL
Speed Slower (HTTP) Faster (wire protocol)
Features REST endpoints only Full SQL support
RLS Automatic Manual session setup
Auth API key DB credentials
Best For Public APIs Backend services

Documentation

Full guide: dbal/production/tests/integration/SUPABASE_TESTING.md

Topics covered:

  • Setup options (hosted, local, minimal)
  • Backend configurations
  • Multi-tenant support
  • Troubleshooting
  • Performance testing
  • Security best practices

Next Steps

  1. Create Supabase project (or install local CLI)
  2. Set environment variables (URL + keys)
  3. Run test matrix:
    python3 dev-container.py test-matrix
    
  4. Review results for all 8 backends
  5. Deploy to production with chosen backend

Benefits

  • Managed PostgreSQL: No database administration
  • Built-in Auth: User authentication out of the box
  • Real-time: WebSocket subscriptions
  • Storage: S3-compatible file storage
  • Edge Functions: Serverless compute
  • RLS: Row-level security for multi-tenancy
  • Free Tier: 500MB database, 2GB file storage

Integration Status

Test Infrastructure: Supabase backends added to matrix
Docker Compose: Environment variables configured
CLI Tool: dev-container.py updated
Documentation: Comprehensive testing guide
Configuration: REST + PostgreSQL modes

Ready to test! Full 8-backend validation available.