++ed by:

13 PAUSE users
16 non-PAUSE users.

David E. Wheeler


sqitch-add - Add a database change to the plan


  sqitch [options] add [<dependency-options>] [<template-options>] name


Add a database change to the plan. This will result in the creation of a new script files with the --extension extension in the --deploy-dir, --revert-dir, and --test-dir directories. The content of these files is determined by the evaluation of templates. By default, system templates in $(etc_path)/templates are used. These can be overridden by a single user by creating templates in ~/.sqitch/templates/ See "Templates" for details.



Name of a change that is required by the new change. May be specified multiple times.


Name of a change that conflicts with the new change. May be specified multiple times.


Set a variable name and value for use in the templates. The format must be name=value, e.g., --set comment='This one is for you, babe.'.


Location to look for the templates. If none is specified, add will first look in ~/.sqitch/templates/ for each template, and fall back on $($etc_prefix)/templates.


Path to the template for the given change script. Defaults to the individual templates found in --template-directory.


Do not generate the named script.


Generate the named script. These are not mutually exclusive.


Sqitch contains a very simple set of templates for generating the deploy, revert, and test scripts. By default, it uses system-wide templates installed in ($etc_path)/templates; call sqitch --etc-path to find out where, exactly. Individual templates may be overridden on a user bases by copying templates to ~/.sqitch/tempates and making modifications. They may also be overridden by using the --tmplaet-directory option, as well as the template-specific options.


The syntax of the templates is the very simple but limited language provided by Template::Tiny, which is limited to:

[% %]

This is the directive syntax. By default, the return value of the expression is output:

  -- Deploy [% change %]

You can add - to the immediate start or end of a directive tag to control the whitespace chomping options:

  [% IF foo -%]    # remove trailing newline
  We have foo!
  [%- END %]       # remove leading newline
[% IF %]
[% IF %] / [% ELSE %]
[% UNLESS %]

Conditional blocks:

  [% IF transactions  %]
  [% ELSE %]
  -- No transaction, beware!
  [% END %]
[% FOREACH item IN list %]

Loop over a list of values:

  [% FOREACH item IN requires -%]
  -- requires: [% item %]
  [% END -%]


Sqitch defines three variables for all templates. Any number of additional variables can be added via the --set option, like so:

  sqitch add --set transations=1 --set schema=foo

Any number of variables may be specified in this manner. You may then use those variables in custom templates. Variables that appear multiple times will be passed to the templates as lists of values for which you will likely want to use [% FOREACH %]. If the templates do not reference your variables, they will be ignored. Variables may also be specified in a [add "variables] config section (see "Configuration Variables"). Variables specified via --set will override configuration variables.

The three core variables are:


The name of the change being added.


A list of required changes as passed via one or more instances of the --requiers option.


A list of conflicting changes as passed via one or more instances of the --requiers option.

Configuration Variables


Directory in which to find the templates which should be named deploy.tmpl, revert.tmpl, and test.tmpl. This will override looking for user- or system-specific templates, and may in turn be overridden by the --template-directory, --deploy-template, --revert-template, and --test-template options.


Boolean variable indicating whether or not to generate the specified script when adding a change. They are all enabled by default. If you've disabled them but wish to create them for a given call to add, use the appropriate option: --deploy, --revert, or --test.


Location of individual templates. My be overridden by the appropriate option: --deploy-template, --revert-template, or --test-template.


A section defining template variables. Useful if you've customized templates with your own variables and want project-, user-, or system-specific defaults for them.


Unless explicitly told where to find templates via --template-directory or, as appropriate, --deploy-template, --user-template or --test-template, Sqitch looks in two locations for templates: A system-wide location and a user-specific location:


The system-wide templates for creating deploy, revert, and test scripts.


User-specific templates to override the system-wide templates.


Part of the sqitch suite.