=head1 Name

sqitch-verify - Verify deployed database changes

=head1 Synopsis

  sqitch verify [options] [<database>]
  sqitch verify [options] --from-change <change>
  sqitch verify [options] --to-change <change>
  sqitch verify [options] --from-change <change> --to-change <change>

=head1 Description

Verify that a database is valid relative to the plan and the verification
scripts for each deployed change.

More specifically, C<verify> iterates over all deployed and planned changes
(or the subset identified by C<--from-change> and/or C<--to-change>) and
checks that each:

=over

=item *

Is deployed.

=item *

Is present in the plan.

=item *

Was deployed in the proper order.

=item *

Passes its verify test, if one exists and the change has not been reworked.

=back

The C<< <database> >> parameter specifies the database to which to connect,
and may also be specified as the C<--target> option. It can be target name,
a URI, an engine name, or plan file path.

Verify tests are scripts that may be associated with each change. If a change
has no verify script, a warning is emitted, but it is not considered a
failure. If a change has been reworked, only the most recent reworking will
have its verify script executed.

Verify scripts should make no assumptions about the contents of the database,
as unit tests might. Rather, their job is to ensure that the state of a
database is correct after a deploy script has completed. Verify scripts are
run through the database engine command-line client, just like deploy and
revert scripts. They should cause the client to exit with a non-zero exit code
if they fail.

=head1 Options

=over

=item C<-t>

=item C<--target>

The target database to which to connect. This option can be either a URI or
the name of a target in the configuration.

=item C<--from-change>

=item C<--from>

Specify the change with which to start the verification. Defaults to the
earliest deployed change. See L<sqitchchanges> for the various ways in which
changes can be specified.

=item C<--to-change>

=item C<--to>

Specify the change with which to complete the verification. Defaults to the
last deployed change. See L<sqitchchanges> for the various ways in which
changes can be specified.

=item C<-s>

=item C<--set>

Set a variable name and value for use by the database engine client, if it
supports variables. The format must be C<name=value>, e.g.,
C<--set defuser='Homer Simpson'>. Overrides any values loaded from
L</configuration Variables>.

=item C<--registry>

  sqitch verify --registry registry

The name of the Sqitch registry schema or database in which sqitch stores its
own data.

=item C<--db-client>

=item C<--client>

  sqitch verify --client /usr/local/pgsql/bin/psql

Path to the command-line client for the database engine. Defaults to a client
in the current path named appropriately for the database engine.

=item C<-d>

=item C<--db-name>

  sqitch verify --db-name widgets
  sqitch verify -d bricolage

Name of the database. In general, L<targets|sqitch-target> and URIs are
preferred, but this option can be used to override the database name in a
target.

=item C<-u>

=item C<--db-user>

=item C<--db-username>

  sqitch verify --db-username root
  sqitch verify --db-user postgres
  sqitch verify -u Mom

User name to use when connecting to the database. Does not apply to all
engines. In general, L<targets|sqitch-target> and URIs are preferred, but this
option can be used to override the user name in a target.

=item C<-h>

=item C<--db-host>

  sqitch verify --db-host db.example.com
  sqitch verify -h appdb.example.net

Host name to use when connecting to the database. Does not apply to all
engines. In general, L<targets|sqitch-target> and URIs are preferred, but this
option can be used to override the host name in a target.

=item C<-p>

=item C<--db-port>

  sqitch verify --db-port 7654
  sqitch verify -p 5431

Port number to connect to. Does not apply to all engines. In general,
L<targets|sqitch-target> and URIs are preferred, but this option can be used
to override the port in a target.

=item C<--plan-file>

=item C<-f>

  sqitch verify --plan-file my.plan

Path to the deployment plan file. Overrides target, engine, and core
configuration values. Defaults to F<$top_dir/sqitch.plan>.

=back

=head1 Configuration Variables

=over

=item C<[deploy.variables]>

=item C<[verify.variables]>

A section defining database client variables. The C<deploy.variables>
configuration is read from the C<deploy> command configuration, on the
assumption that the values will generally be the same on verify. If they're
not, use C<verify.variables> to override C<deploy.variables>.

These variables are useful if your database engine supports variables in
scripts, such as PostgreSQL's
L<C<psql> variables|https://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-INTERPOLATION>,
Vertica's
L<C<vsql> variables|https://my.vertica.com/docs/7.1.x/HTML/index.htm#Authoring/ConnectingToHPVertica/vsql/Variables.htm>,
MySQL's
L<user variables|https://dev.mysql.com/doc/refman/5.6/en/user-variables.html>,
SQL*Plus's
L<C<DEFINE> variables|https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12017.htm>,
and Snowflake's
L<SnowSQL variables|https://docs.snowflake.com/en/user-guide/snowsql-use.html#using-variables>.

May be overridden by C<--set> or target and engine configuration. Variables
are merged in the following priority order:

=over

=item C<--set>

=item C<target.$target.variables>

=item C<engine.$engine.variables>

=item C<verify.variables>

=item C<deploy.variables>

=item C<core.variables>

=back

=back

=head1 Sqitch

Part of the L<sqitch> suite.
