Skip to content

Pro migrations

Pro features often require additional migration lines to carry out tasks like adding additional indexes for Pro-specific features. This page describes how to install the River Pro CLI, using it continuous integration environments like GitHub Actions, and invoking migrations from Go code.

Each specific Pro feature may or may not require a migration line, and migration lines need only be run for Pro features that a project intends to use. For example, the workflows migration line should only be raised when using workflows.


Installing the River Pro CLI

River Pro distributes an alternate riverpro CLI which contains all the normal river CLI commands and functionality, but with additions specifically for use with Pro. Configure your environment to install River Pro (including GOPROXY/GONOSUMDB) and install the CLI with:

go install riverqueue.com/riverpro/cmd/riverpro@latest

With the DATABASE_URL of a target database (looks like postgres://host:5432/db), migrate up:

# first, install the standard River migrations
riverpro migrate-up --database-url "$DATABASE_URL"

# then add Pro migration lines according to the features you intend to use:
riverpro migrate-up --database-url "$DATABASE_URL" --line sequence
riverpro migrate-up --database-url "$DATABASE_URL" --line workflow

The riverpro CLI must be used for Pro migrations

The main River project distributes its own river CLI to run migrations, but when running Pro migration lines, the riverpro CLI must be used instead. The non-Pro CLI doesn't know about them.

See also installing in CI and build environments.

Running Pro migration lines from Go

Like with the main River project, migrations are runnable from Go code. Make sure to use the riverpropgxv5 driver instead of riverpgxv5, and specify an optional Line property to target a Pro line:

migrator := rivermigrate.New(riverpropgxv5.New(dbPool), &rivermigrate.Config{
    Line: "workflows",
})

res, err := migrator.MigrateTx(ctx, tx, rivermigrate.DirectionUp, &rivermigrate.MigrateOpts{})
if err != nil {
    // handle error
}

Leaving Line empty will default to the main River migration line.