Skip to content

Update pgflow

This guide explains how to update pgflow to the latest version, including package updates and database migrations. pgflow updates involve two main components that need to be updated together.

When updating pgflow, you need to update:

  1. npm packages - CLI, core libraries, client, and DSL packages
  2. JSR package - The Edge Worker package (published to JSR registry)
  3. Database migrations - Schema and function updates

Update all pgflow npm packages to the latest version:

npm update @pgflow/client # or @pgflow/dsl, @pgflow/core etc.

Or if using yarn:

yarn upgrade @pgflow/client # or @pgflow/dsl, @pgflow/core etc.

Or if using pnpm:

pnpm update @pgflow/client # or @pgflow/dsl, @pgflow/core etc.

Update the Edge Worker package in your JSR imports. In your Edge Function files, update the import:

// Before
import { EdgeWorker } from "jsr:@pgflow/edge-worker@^0.5.0";
// After (replace with latest version)
import { EdgeWorker } from "jsr:@pgflow/edge-worker@^0.6.0";

3. Run pgflow install to update migrations

Section titled “3. Run pgflow install to update migrations”

Always run the install command after updating packages to check for and apply new database migrations:

npx pgflow@latest install

The install command will:

  • Detect any new migrations that need to be installed
  • Copy new migrations with timestamps that place them after your existing migrations
  • Skip migrations that are already installed
  • Show you exactly which migrations will be added before proceeding

4. Apply configuration changes (if needed)

Section titled “4. Apply configuration changes (if needed)”

If the installer made configuration changes, restart your Supabase instance:

npx supabase stop
npx supabase start

Apply the new migrations to your database:

npx supabase migrations up

pgflow uses a simple but effective migration system to ensure migrations are applied correctly:

pgflow migrations follow this naming pattern when installed:

[NEW_TIMESTAMP]_[ORIGINAL_TIMESTAMP]_[ORIGINAL_NAME].sql

Where:

  • NEW_TIMESTAMP - Generated timestamp that makes this the newest migration in your folder
  • ORIGINAL_TIMESTAMP - The original pgflow migration timestamp
  • ORIGINAL_NAME - The original migration file name

The original timestamp allows pgflow to search for and detect which migrations have already been installed, while the new timestamp prefix ensures Supabase can apply the migration without timestamp ordering errors.

If pgflow install reports “All pgflow migrations are already in place”, this means:

  • You already have the latest migrations installed
  • No database schema updates are needed for this version
  • You can proceed with using the updated packages

If you encounter issues after updating, verify all packages are on the same version:

npm list | grep pgflow

All pgflow packages should show the same version number.

If you encounter migration conflicts:

  1. Check if you have custom migrations that conflict with pgflow schema
  2. Review the migration files in supabase/migrations/ for any obvious conflicts
  3. Consider using the manual installation approach for more granular control
  • Patch releases - Safe to update immediately, include bug fixes and small backward-compatible improvements
  • Minor releases - Review changelog carefully as these may contain breaking changes
  • Major release to 1.0 - Production-ready milestone, will include comprehensive migration guide
  • Check the pgflow releases page for release notes
  • Review changelog files for detailed changes
  • Test updates in a development environment first

In development, you can update frequently to take advantage of new features and bug fixes:

npm update pgflow @pgflow/core @pgflow/client @pgflow/dsl
npx pgflow@latest install -y # Auto-confirm for faster development
npx supabase migrations up

For production updates, follow a more careful approach:

  1. Test the update in a staging environment first
  2. Review all new migrations carefully
  3. Plan for any necessary downtime
  4. Keep backups of your database before applying migrations
  5. Monitor your flows after updating

Your pgflow installation is now updated with the latest features, bug fixes, and database schema improvements!