Skip to content

# Install pgflow

Let’s set up pgflow in your Supabase project. This setup needs to be done only once per project.

Not production ready

pgflow is currently in Alpha stage and not yet production ready.

Prerequisites

- Supabase CLI version 2.0.2 or higher (check with `supabase -v`)
- A local Supabase project set up
- Deno version 1.45.2 (required for flow compilation)

If you haven’t installed the CLI yet or need to upgrade, see Supabase’s installation guide.

### 1. Install pgflow

Section titled “1. Install pgflow”

You can install pgflow using the automatic installer (recommended) or manually if you want more control over the process.

Run the automatic installer with npx:

    npx pgflow@latest install

The installer will:

- Detect your Supabase project automatically or allow you to specify it manually
- Update your `config.toml` to enable connection pooling
- Copy the required migrations to your migrations folder (with timestamps that ensure they run after your existing migrations)
- Create a functions environment file if needed
- Prevent duplicate migrations if you run the installer multiple times

### 2. Apply configuration changes

Section titled “2. Apply configuration changes”

Restart your Supabase instance to apply the configuration changes:

    npx supabase stopnpx supabase start

### 3. Apply migrations

Section titled “3. Apply migrations”

If you haven’t already, apply the migrations to create the pgflow schema and tables:

    npx supabase migrations up

#### What was installed?

Section titled “What was installed?”

The installer set up:

1. Database schema - Tables for workflow definitions and runtime state
2. SQL functions - Core functions to create, start, and manage workflows
3. Connection pooling - Required for Edge Worker operation
4. Environment variables - Database connection for Edge Functions
5. Smart migrations - Migration files are copied with timestamps that ensure they run after your existing migrations and won’t be duplicated if you upgrade pgflow later

About migrations

When installing or upgrading pgflow, migrations are copied with special timestamp prefixes that ensure they:

- Run after your existing project migrations
- Won’t conflict with your own migrations
- Won’t be duplicated if you run the installer multiple times

For example, a pgflow migration like `20250429164909_pgflow_initial.sql` might be installed as `20250430000010_20250429164909_pgflow_initial.sql` to preserve order and prevent conflicts.

Your Supabase project now has everything needed to create and run workflows with pgflow!