App-Sqitch

 view release on metacpan or  search on metacpan

lib/sqitchtutorial-exasol.pod  view on Meta::CPAN

  > sqitch verify 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  Verifying db:exasol://sys:@localhost:8563/?Driver=Exasol
  * appschema .. Error: [42000] schema NONESUCH not found [line 1, column 40] (Session: 1582884049218108749)

  # 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 exa_schemas WHERE schema_name = 'nonesuch';

Then the verify will look something like:

  > sqitch verify 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  Verifying db:exasol://sys:@localhost:8563/?Driver=Exasol
  * appschema .. Error: [22012] data exception - division by zero (Session: 1582884446489810101)

  # 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:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  # On database db:exasol://sys:@localhost:8563/?Driver=Exasol
  # 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:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  Revert all changes from db:exasol://sys:@localhost:8563/?Driver=Exasol? [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:

> exaplus -q -u sys -p exasol -c localhost:8563 -sql "select schema_name from exa_schemas;"

  SCHEMA_NAME
  --------------------------------------------------------------------------------------------------------------------------------
  SQITCH

And the status message should reflect as much:

  > sqitch status 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  # On database db:exasol://sys:@localhost:8563/?Driver=Exasol
  No changes deployed

Of course, since nothing is deployed, the L<C<verify>|sqitch-verify> command
has nothing to verify:

  > sqitch verify 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  Verifying db:exasol://sys:@localhost:8563/?Driver=Exasol
  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:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  On database db:exasol://sys:@localhost:8563/?Driver=Exasol
  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:exasol://sys:exasol@localhost:8563/?Driver=Exasol'
  Deploying changes to db:exasol://sys:@localhost:8563/?Driver=Exasol



( run in 1.018 second using v1.01-cache-2.11-cpan-6aa56a78535 )