Databases

Telbase provisions managed databases automatically when it detects an ORM in your project. No configuration, no connection strings to copy — just deploy.

How It Works

When you run telbase deploy, the CLI scans your project for an ORM (Prisma, Drizzle, Django, SQLAlchemy, GORM, or Ent). If it finds one, it provisions the right database on first deploy:

The DATABASE_URL environment variable is set automatically. Your code connects to the database without any changes.

Customer-facing terms
Telbase uses SQLite and PostgreSQL in all user-facing contexts. The underlying providers (Turso for SQLite, Neon for PostgreSQL) are transparent to you.

SQLite vs PostgreSQL

Best for most internal tools. Simple, fast, no connection pooling to worry about.

  • Single-file database, replicated globally
  • Microsecond reads at the edge
  • Works with any compute provider (Vercel, GCP)
  • Ideal for: dashboards, approval workflows, trackers, CRUD apps

Use SQLite when your Prisma schema has provider = "sqlite" or url = "file:./dev.db".

Migrations

Migrations run automatically on every deploy. Telbase detects your migration tool (Prisma Migrate or Drizzle Kit) and injects the migration command into the build step. No manual intervention needed.

bash
# Check which migrations have been applied
telbase db migrate:status

# Run migrations manually (if needed)
telbase db migrate

# Preview without applying
telbase db migrate --dry-run
Automatic migration injection
You never need to add migration commands to your build scripts. Telbase prepends npx prisma migrate deploy (or the Drizzle equivalent) to your build command automatically.

Querying Your Database

Run SQL directly from the CLI. Useful for debugging, data inspection, and one-off queries.

Read-only queries

bash
# SELECT, WITH, and EXPLAIN queries (max 1,000 rows)
telbase db query "SELECT count(*) FROM users"

# From a file
telbase db query --file analytics.sql

Write queries

bash
# INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE
telbase db exec "UPDATE users SET role = 'admin' WHERE email = '[email protected]'"

# From a file
telbase db exec --file seed.sql

Interactive session (PostgreSQL)

bash
# Opens a psql session connected to your database
telbase db connect

Backups

Paid plans include automatic daily backups and manual snapshot support.

bash
# Create a manual backup
telbase db backup --name "before-migration"

# List all backups
telbase db backups

# Restore from a backup
telbase db restore <backup-id>

# Restore the most recent backup
telbase db restore --latest
Paid plans only
Backups and restore are available on Starter ($5/mo) and above. See pricing for details.

PostgreSQL Extensions

Enable popular PostgreSQL extensions directly from the CLI. Telbase supports pgvector, pg_trgm, PostGIS, and uuid-ossp.

bash
# List available extensions
telbase db extensions

# Enable pgvector for AI embeddings
telbase db enable-extension pgvector

Embedding presets

When enabling pgvector, use a preset to auto-configure the vector dimensions and create a sample embeddings table:

bash
# OpenAI text-embedding-3-small (1536 dimensions)
telbase db enable-extension pgvector --preset openai-3-small --create-table

# OpenAI text-embedding-3-large (3072 dimensions)
telbase db enable-extension pgvector --preset openai-3-large --create-table

# Voyage AI embeddings (1024 dimensions)
telbase db enable-extension pgvector --preset claude --create-table

# Custom dimensions
telbase db enable-extension pgvector --dimensions 384 --create-table

Available presets: openai-ada-002, openai-3-small, openai-3-large, claude, cohere-english, sentence-transformers.

For a complete guide on auto-detection, embedding presets, and deploying RAG applications, see Vector Search & RAG.

Index configuration
By default, pgvector creates an HNSW index with cosine distance. You can customize with --index-type (hnsw, ivfflat, none) and --metric (cosine, l2, inner_product).

Environment Variables

DATABASE_URL is set automatically when a database is provisioned. To access it locally for development:

bash
# Download all env vars to .env.local
telbase env pull

# View the connection string
telbase env get DATABASE_URL

If you need additional database-related variables (e.g., a read-only replica URL or a direct connection for migrations), set them with:

bash
telbase env set DIRECT_URL=postgres://... --secret

Next Steps