Set up
Deploy Postgres
You can self-host Postgres or use a managed service (e.g. AWS RDS, Supabase, PlanetScale).
Follow the deployment instructions for your chosen service.
If you find any compatibility issues, please open a detailed GitHub Discussion.
Set up Postgres extensions
TensorZero requires the following Postgres extensions:Here are example setup instructions for some popular Postgres providers.
See the AWS documentation for more details.
See the Cloud SQL documentation for more details.
See the PlanetScale documentation for more details.
Self-Hosted Postgres
Self-Hosted Postgres
For convenience, we publish If you use a non-default Postgres user for TensorZero, connect to your database and run:
tensorzero/postgres Docker images that bundle all required extensions on top of the official Postgres image.If you prefer to set up extensions yourself, install pg_cron, pgvector, and pg_trgm.Regardless of how you install the extensions, you must set cron.database_name to the database used by TensorZero. You can do this via a CLI flag (postgres -c cron.database_name=tensorzero) or in postgresql.conf:postgresql.conf
AWS RDS
AWS RDS
Configure the parameter group
Create a custom parameter group if you haven’t already. Add
pg_cron to the shared_preload_libraries parameter and set cron.database_name to your TensorZero database name.GCP Cloud SQL
GCP Cloud SQL
Configure database flags
Set the
cloudsql.enable_pg_cron database flag to on and set the cron.database_name database flag to your TensorZero database name.Supabase
Supabase
Enable See the Supabase documentation for more details.
pg_cron, vector, and pg_trgm from the Database Extensions page in your Supabase dashboard, or run:PlanetScale
PlanetScale
Enable extensions in the dashboard
In the PlanetScale dashboard, select your database and navigate to Clusters. Select the branch to configure, then go to the Extensions tab. Enable
pg_cron, vector, and pg_trgm, set cron.database_name to your TensorZero database name, then click Queue extension changes and Apply changes.Configure TensorZero
To configure TensorZero to use Postgres, set the
TENSORZERO_POSTGRES_URL environment variable with your Postgres connection details..env
Apply Postgres migrations
You must apply migrations manually with
gateway --run-postgres-migrations.
See Deploy the TensorZero Gateway for more details.- Docker Compose
- Docker
If you’ve configured the gateway with Docker Compose, you can run the migrations with:
You should re-run this command when upgrading TensorZero from an earlier version.