Skip to main content
The roll commands help you manage database migrations using pgroll.
You can override the pgroll binary version used by the CLI via the XATA_PGROLL_BINARY_VERSION environment variable. See Binary Version Overrides for details.

Subcommands

baseline

Create a baseline migration for an existing database schema.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Create version schemas for each migration
boolean
Enable verbose logging
boolean
Output in JSON format instead of YAML
boolean
Skip confirmation prompt
boolean
Print help information and exit
string
Name of the migration (e.g., “01_initial_schema”)
string
The directory that contains the migrations (default: .xata/migrations)

complete

Complete an ongoing migration with the operations present in the given file.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Create version schemas for each migration
boolean
Enable verbose logging
boolean
Print help information and exit

init

Initialize pgroll in the target database.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Create version schemas for each migration
boolean
Enable verbose logging
boolean
Print help information and exit

latest

Print the name of the latest schema version, either in the target database or a local directory.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Retrieve the latest version from a local migration directory
boolean
Prefix the version with the schema name
boolean
Print help information and exit

migrate

Apply outstanding migrations from a directory to a database.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
string
Duration of delay between batch backfills (eg. 1s, 1000ms)
number
Number of rows backfilled in each batch
boolean
Complete the final migration rather than leaving it active
boolean
Print help information and exit
string
The directory that contains the migrations (default: .xata/migrations)

update

Update outdated migrations in a directory.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Print help information and exit
string
The directory that contains the migrations (default: .xata/migrations)

pull

Pull migration history from the target database and write it to disk.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Output each migration in JSON format instead of YAML
boolean
Prefix each migration filename with its position in the schema history
boolean
Print help information and exit
string
The target directory to pull migrations into (default: .xata/migrations)

rollback

Roll back an ongoing migration.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Print help information and exit

start

Start a migration for the operations present in the given file.
string
required
The migration file to start
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Create version schemas for each migration
boolean
Enable verbose logging
string
Duration of delay between batch backfills (eg. 1s, 1000ms)
number
Number of rows backfilled in each batch
boolean
Mark the migration as complete
boolean
Skip migration validation
boolean
Print help information and exit

status

Show pgroll status.
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Print help information and exit

convert

Convert SQL statements to a pgroll migration.
string
required
The migration file to start
number
Postgres lock timeout in milliseconds for pgroll DDL operations
string
Postgres schema to use for pgroll internal state
string
Postgres URL
string
Optional postgres role to set when executing migrations
string
Postgres schema to use for the migration
boolean
Enable verbose logging
boolean
Output migration file in JSON format instead of YAML
boolean
Print help information and exit

Global Flags

boolean
Print help information and exit