App-Sqitch

 view release on metacpan or  search on metacpan

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

command:

  > sqitch verify db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  Verifying db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
    * users .. ok
  Verify successful

Looks good! If you want to make sure that the verify script correctly dies if
the table doesn't exist, temporarily change the table name in the script to
something that doesn't exist, something like:

  SELECT nickname, password, fullname, twitter, created_at
    FROM users_nonesuch
   WHERE 1=2;

Then L<C<verify>|sqitch-verify> again:

  > sqitch verify db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  Verifying db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
    * users .. Statement failed, SQLSTATE = 42S02
  Dynamic SQL Error
  -SQL error code = -204
  -Table unknown
  -USERS_NONESUCH
  -At line 3, column 2
  At line 3 in file verify/users.sql
  # Verify script "verify/users.sql" failed.
  not ok

  Verify Summary Report
  ---------------------
  Changes: 1
  Errors:  1
  Verify failed

Firebird is kind enough to tell us what the problem is. Don't forget to change
the table 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 tables
from the registry database:

  > sqitch status db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  # On database db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
  # Project:  flipr
  # Change:   2cde9cc8c19161e9837de57741502243b2ad380e
  # Name:     users
  # Deployed: 2014-01-05 14:05:22 -0800
  # 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:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  Revert all changes from db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb? [Yes] 
    - users .. 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 C<users> table should be gone:

  > echo "CONNECT 'localhost:/tmp/flipr_test/flipr.fdb'; SHOW TABLES; quit;" \
    | isql-fb -q -u SYSDBA -p masterkey
  There are no tables in this database

And the status message should reflect as much:

  > sqitch status db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  # On database db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
  No changes deployed

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

  > sqitch verify db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  Verifying db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
  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:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb
  On database db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
  Revert 2cde9cc8c19161e9837de57741502243b2ad380e
  Name:      users
  Committer: Marge N. O’Vera <marge@example.com>
  Date:      2014-01-05 14:06:59 -0800

      Creates table to track our users.

  Deploy 2cde9cc8c19161e9837de57741502243b2ad380e
  Name:      users
  Committer: Marge N. O’Vera <marge@example.com>
  Date:      2014-01-05 14:05:22 -0800

      Creates table to track our users.


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 users table.'
  [main ec72105] Add users table.
   4 files changed, 24 insertions(+), 0 deletions(-)
   create mode 100644 deploy/users.sql
   create mode 100644 revert/users.sql
   create mode 100644 verify/users.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 db:firebird://sysdba:masterkey@localhost//tmp/flipr_test/flipr.fdb --verify
  Deploying changes to db:firebird://sysdba:@localhost//tmp/flipr_test/flipr.fdb
    + users .. ok



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