App-Sqitch
view release on metacpan or search on metacpan
lib/sqitchtutorial-vertica.pod view on Meta::CPAN
Then L<C<verify>|sqitch-verify> again:
> sqitch verify 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
Verifying db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
* appschema .. vsql:verify/appschema.sql:5: ROLLBACK 4650: Schema "nonesuch" does not exist
# Verify script "verify/appschema.sql" failed.
not ok
Verify Summary Report
---------------------
Changes: 1
Errors: 1
Verify failed
It's even nice enough to tell us what the problem is. Or, for the
divide-by-zero example, change the schema name:
SELECT 1/COUNT(*) FROM v_catalog.schemata WHERE schema_name = 'nonesuch';
Then the verify will look something like:
> sqitch verify 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
Verifying db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
* appschema .. vsql:verify/appschema.sql:5: ERROR 2005: division by zero
# Verify script "verify/appschema.sql" failed.
not ok
Verify Summary Report
---------------------
Changes: 1
Errors: 1
Verify failed
Less useful error output, but enough to alert us that something has gone
wrong.
Don't forget to change the schema name back before continuing!
=head2 Status, Revert, Log, Repeat
For purely informational purposes, we can always see how a deployment was
recorded via the L<C<status>|sqitch-status> command, which reads the registry
tables from the database:
> sqitch status 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
# On database db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
# Project: flipr
# Change: f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764
# Name: appschema
# Deployed: 2014-09-04 15:26:28 -0700
# By: Marge N. OâVera <marge@example.com>
#
Nothing to deploy (up-to-date)
Let's make sure that we can revert the change:
> sqitch revert 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
Revert all changes from db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica? [Yes]
- appschema .. ok
The L<C<revert>|sqitch-revert> command first prompts to make sure that we
really do want to revert. This is to prevent unnecessary accidents. You can
pass the C<-y> option to disable the prompt. Also, notice the C<-> before the
change name in the output, which reinforces that the change is being
I<removed> from the database. And now the schema should be gone:
> vsql -U dbadmin -c '\dn flipr'
List of schemas
Name | Owner | Comment
------+-------+---------
(0 rows)
And the status message should reflect as much:
> sqitch status 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
# On database db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
No changes deployed
Of course, since nothing is deployed, the L<C<verify>|sqitch-verify> command
has nothing to verify:
> sqitch verify 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
Verifying db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
No changes deployed
However, we still have a record that the change happened, visible via the
L<C<log>|sqitch-log> command:
> sqitch log 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
On database db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
Revert f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764
Name: appschema
Committer: Marge N. OâVera <marge@example.com>
Date: 2014-09-04 16:33:02 -0700
Add schema for all flipr objects.
Deploy f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764
Name: appschema
Committer: Marge N. OâVera <marge@example.com>
Date: 2014-09-04 15:26:28 -0700
Add schema for all flipr objects.
Note that the actions we took are shown in reverse chronological order, with
the revert first and then the deploy.
Cool. Now let's commit it.
> git add .
> git commit -m 'Add flipr schema.'
[main 9bee4bd] Add flipr schema.
5 files changed, 197 insertions(+), 0 deletions(-)
create mode 100644 deploy/appschema.sql
create mode 100644 revert/appschema.sql
create mode 100644 sqitch.sql
create mode 100644 verify/appschema.sql
And then deploy again. This time, let's use the C<--verify> option, so that
the C<verify> script is applied when the change is deployed:
> sqitch deploy --verify 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica'
Deploying changes to db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica
( run in 0.839 second using v1.01-cache-2.11-cpan-6aa56a78535 )