Skip to content

Command Line Options

Sergey Tregub edited this page Apr 6, 2019 · 6 revisions

init

dbup init [path-to-config/config-name.yml]

Creates a default configuration file in a current directory or at the specified location.

Option Description
path/to/config/file.yml Optional, by default - dbup.yml. A path to a configuration file. The path can be absolute or relative against a current directory

upgrade

dbup upgrade [path-to-config/config-name.yml] [--ensure] [-e path-to-env]

Runs a database migration:

> dbup upgrade

Beginning transaction
Beginning database upgrade
Checking whether journal table exists..
Fetching list of already executed scripts.
Executing Database Server script '002.sql'
Checking whether journal table exists..
Upgrade successful
Option Description
--ensure Create a database if not exists
-e, --env Path to an environment file. Can be more than one file specified divided by space. The path can be absolute or relative against a current directory
path/to/config/file.yml Optional, by default - dbup.yml. A path to a configuration file. The path can be absolute or relative against a current directory
-v, --verbosity Verbosity level. Can be one of detail, normal or min. By default uses normal. See below.

Verbosity level

Verbosity Descripton
min If you want to see neither output from DbUp engine nor scripts output
normal If you want to see the output from DbUp engine
detail If you want to see scripts output as well as output from DbUp engine. For example, the string PRINT 'Hello from SQL-script'in your SQL-script will print Hello from SQL-script to the console.

status

dbup status [path-to-config/config-name.yml] [-x] [-n] [-e path-to-env]

Displays migration status. If the database is up-to-date, the command finishes with exit code 0:

Database is up-to-date. Upgrade is not required.

If migration is required, it finishes with code -1:

> dbup status

Database upgrade is required.
You have 1 more scripts to execute.

You can get more information using '-x' and '-n' options:

> dbup status -x -n

Database upgrade is required.
You have 1 more script(-s) to execute.

These scripts will be executed:
    002.sql

Already executed scripts:
    001.sql
Option Description
-x, --show-executed (Default: false) Print names of executed scripts
-n, --show-not-executed (Default: false) Print names of scripts to be executed
-e, --env Path to an environment file. Can be more than one file specified divided by space. The path can be absolute or relative against a current directory
path/to/config/file.yml Optional, by default - dbup.yml. A path to a configuration file. The path can be absolute or relative against a current directory

mark-as-executed

dbup mark-as-executed [path-to-config/config-name.yml] [-e path-to-env]

Does the same things the 'upgrade' command does, but without actual execution of the scripts. This feature can be useful when you for some reason have already executed scripts by hands and do not want these scripts will be executed during the next migration.

Option Description
--ensure Create a database if not exists
-e, --env Path to an environment file. Can be more than one file specified divided by space. The path can be absolute or relative against a current directory
path/to/config/file.yml Optional, by default - dbup.yml. A path to a configuration file. The path can be absolute or relative against a current directory
-v, --verbosity Verbosity level. Can be one of detail, normal or min. By default uses normal. See upgrade command for details.

drop

dbup drop [path-to-config/config-name.yml] [-e path-to-env]

Drops the database.

Option Description
-e, --env Path to an environment file. Can be more than one file specified divided by space. The path can be absolute or relative against a current directory
path/to/config/file.yml Optional, by default - dbup.yml. A path to a configuration file. The path can be absolute or relative against a current directory.

version

dbup version

Displays a current version.

help

dbup help

Displays a brief description of all of the commands. To get more information about a specific command type command name after 'help':

dbup help upgrade