Name

sqitch-target - Manage target database configuration

Synopsis

sqitch target
sqitch target [-v | --verbose]
sqitch target add <name> <uri> [-s <property>=<value> ...]
sqitch target alter <name> [-s <property>=<value> ...]
sqitch target remove <name>
sqitch target rename <old> <new>
sqitch target show <name> [...]

Description

Manage the set of databases ("targets") you deploy to. Each target may have a number of properties:

uri

The database connection URI for the target. Required. Its format is:

db:engine:[dbname]
db:engine:[//[user[:password]@][host][:port]/][dbname][?params][#fragment]

Some examples:

db:sqlite:widgets.db
db:pg://dba@example.net/blanket
db:mysql://db.example.com/
db:firebird://localhost//tmp/test.fdb

Note that, as with any URI or URL, special characters must be URL encoded. For example, when a username contains a reserved character, such as the | in ro|michelle, it must be percent-encoded as %7c:

db:pg://ro%7Cmichelle@examle.org/inventory

The rules are even more strict for query parameters, as often used by for ODBC connections. For example, when using a Snowflake identifier with special characters, such as a warehouse name with a ., such as sqitch.dev, the identifier must be double-quoted --- and double quote are reserved characters in URIs, so must be encoded as %22.

db:snowflake://example/flipr?Driver=Snowflake;warehouse=%22sqitch.dev%22

See URL encoding for details. and the DB URI Draft for in-depth information on database URIs in general.

registry

The name of the registry schema or database. The default is sqitch.

client

The command-line client to use. If not specified, each engine looks in the OS Path for an appropriate client.

top_dir

The path to the top directory for the target. This directory generally contains the plan file and subdirectories for deploy, revert, and verify scripts, as well as reworked instances of those scripts. The default is ., the current directory.

plan_file

The plan file to use for this target. The default is $top_dir/sqitch.plan.

deploy_dir

The path to the deploy directory for the target. This directory contains all of the deploy scripts referenced by changes in the plan_file. The default is $top_dir/deploy.

revert_dir

The path to the revert directory for the target. This directory contains all of the revert scripts referenced by changes in the plan_file. The default is $top_dir/revert.

verify_dir

The path to the verify directory for the target. This directory contains all of the verify scripts referenced by changes in the plan_file. The default is $top_dir/verify.

reworked_dir

The path to the reworked directory for the target. This directory contains all subdirectories for all reworked scripts referenced by changes in the plan_file. The default is $top_dir.

reworked_deploy_dir

The path to the reworked deploy directory for the target. This directory contains all of the reworked deploy scripts referenced by changes in the plan_file. The default is $reworked_dir/deploy.

reworked_revert_dir

The path to the reworked revert directory for the target. This directory contains all of the reworked revert scripts referenced by changes in the plan_file. The default is $reworked_dir/revert.

reworked_verify_dir

The path to the reworked verify directory for the target. This directory contains all of the reworked verify scripts referenced by changes in the plan_file. The default is $reworked_dir/verify.

extension

The file name extension to append to change names to create script file names. The default is sql.

Each of these overrides the corresponding engine-specific configuration managed by engine.

Options

List Option
-v
--verbose
sqitch target --verbose

Be more verbose when listing targets.

Add and Alter Options
--uri
sqitch target add devwidgets --uri db:pg:widgets

Specifies the URI of the target database.

--top-dir
sqitch target add devwidgets --top-dir sql

Specifies the top directory to use for the target. Typically contains the deployment plan file and the change script directories.

--plan-file
-f
sqitch target add devwidgets --plan-file my.plan

Specifies the path to the deployment plan file. Defaults to $top_dir/sqitch.plan.

--extension
sqitch target add devwidgets --extension ddl

Specifies the file name extension to use for change script file names. Defaults to sql.

--dir
sqitch target add devwidgets --dir deploy=dep --dir revert=rev --dir verify=tst

Sets the path to a script directory. May be specified multiple times. Supported keys are:

  • deploy

  • revert

  • verify

  • reworked

  • reworked_deploy

  • reworked_revert

  • reworked_verify

--registry
sqitch target add devwidgets --registry meta

Specifies the name of the database object where Sqitch's state and history data is stored. Typically a schema name (as in PostgreSQL and Oracle) or a database name (as in SQLite and MySQL). Defaults to sqitch.

--client
sqitch target add devwidgets --client /usr/local/pgsql/bin/psql

Specifies the path to the command-line client for the target. Defaults to a client in the current path named appropriately for the engine specified by the URI.

-s
--set

Set a variable name and value for use by the database engine client, if it supports variables. The format must be name=value, e.g., --set defuser='Homer Simpson'.

Actions

With no arguments, shows a list of existing targets. Several actions are available to perform operations on the targets.

add

Add a target named <name> for the database at <uri>. The --set option specifies target-specific properties. A new plan file and new script script directories will be created if they don't already exist.

alter

Alter target named <name>. The --set option specifies engine-specific properties to set. New script script directories will be created if they don't already exist.

remove, rm

Remove the target named <name>. The plan file and script directories will not be affected.

rename

Rename the target named <old> to <new>.

show

Gives some information about the target <name>, including the associated properties. Specify multiple target names to see information for each.

Configuration Variables

The targets are stored in the configuration file, but the command itself currently relies on no configuration variables.

Sqitch

Part of the sqitch suite.