summaryrefslogtreecommitdiff
path: root/lib/sqitch-configuration.pod
blob: a96368565caba977c7125220659c37cc9d650373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
=encoding UTF-8

=head1 Name

sqitch-configuration - Hierarchical engine and target configuration

=head1 Description

The specification of database targets is core to Sqitch database change
management. A target consists of a
L<database connection URI|https://github.com/libwww-perl/uri-db>, a plan file,
change script directories, a registry schema or database name, and the path to
a database engine command-line client. Sqitch determines the values for these
attributes via a hierarchical evaluation of the runtime configuration,
examining and selecting from these values:

=over

=item 1.

Command-line options

=item 2.

Target-specific configuration

=item 3.

Engine-specific configuration

=item 4.

Core configuration

=item 5.

A reasonable default

=back

This document explains how this evaluation works, and how to use the
L<C<init>|sqitch-init>, L<C<config>|sqitch-config>,
L<C<engine>|sqitch-engine>, and L<C<target>|sqitch-target> commands to
configure these values for various deployment scenarios.

=head1 Project Initialization

Typically, the first thing you do with Sqitch is use the
L<C<init>|sqitch-init> command to start a new project. Now, the most important
thing Sqitch needs to know is what database engine you'll be managing, so it's
best to use C<--engine> to configure the engine right up front to start off on
the right foot. Here, we start a project called "widgets" to manage PostgreSQL
databases:

  > sqitch init widgets --engine pg
  Created sqitch.conf
  Created sqitch.plan
  Created deploy/
  Created revert/
  Created verify/

This creates a very simple configuration file with most of the settings
commented out, like so:

  > cat sqitch.conf
  [core]
    engine = pg
    # plan_file = sqitch.plan
    # top_dir = .
  # [engine "pg"]
    # target = db:pg:
    # registry = sqitch
    # client = psql

The C<[core]> section contains default configurations, the most important of
which is the default engine, C<pg>. Of course, it's the I<only> engine this
project supports, and the values of the other configuration variables are
reasonable for a single-engine project. If your Sqitch project never needs to
manage more than one database engine, this might be all you need: the current
directory is the top directory of the project, and it's here you'll find the
plan file as well as the deploy, revert, and verify script directories. Once
you start using the L<C<add>|sqitch-add> command to add changes, and the
L<C<deploy>|sqitch-deploy> command to deploy changes to a database, these
variables will be used extensively.

The C<[engine "pg"]> section houses the variables specific to the engine. The
C<target> defines the default L<database URI|https://github.com/libwww-perl/uri-db>
for connecting to a PostgreSQL database. As you can see there isn't much here,
but if you were to distribute this project, it's likely that your users would
specify a target URI when deploying to their own databases. The C<registry>
determines where Sqitch will store its own metadata when managing a database;
generally the default, "sqitch", is fine.

More interesting, perhaps, is the C<client> setting, which defaults to the
appropriate engine-specific client name appropriate for your OS. In this
example, sqitch will assume it can find F<psql> in your path.

=head1 Global Configuration

But sometimes that's not the case. Let's say that the C<psql> client on your
system is not in the path, but instead in F</usr/local/pgsql/bin/psql>. You
could set its location right here in the project configuration file, but that
won't do if you end up distributing the project to other users who might have
their client somewhere else. For that use case, the default path-specific
value is probably best.

A better idea is to tell Sqitch where to find F<psql> for I<all> of your
projects. Use the L<C<config>|sqitch-config> command's C<--user> option to set
that configuration for yourself:

  > sqitch config --user engine.pg.client /usr/local/pgsql/bin/psql

This won't change the project configuration file at all, but add the value to
F<~/.sqitch/sqitch.conf>, which is your personal cross-project Sqitch
configuration. In other words, it sets the PostgreSQL client for all Sqitch
projects you manage on this host. In fact, it can be a good idea to configure
clients not in the path first thing whenever you start working on a new host:

  > sqitch config --user user.name 'Marge N. O’Vera'
  > sqitch config --user user.email 'marge@example.com'
  > sqitch config --user engine.pg.client /usr/local/pgsql/bin/psql
  > sqitch config --user engine.mysql.client /usr/local/mysql/bin/mysql
  > sqitch config --user engine.sqlite.client /sbin/sqlite3

If you'd like to make the configuration global to all accounts on your host,
use the C<--system> option, instead:

  > sudo sqitch config --system engine.pg.client /usr/local/pgsql/bin/psql
  > sudo sqitch config --system engine.mysql.client /usr/local/mysql/bin/mysql
  > sudo sqitch config --system engine.sqlite.client /sbin/sqlite3

That will put the values into the global Sqitch configuration file, which is
in C<`sqitch --etc-path`/sqitch.conf>.

=head1 Engine Configuration

So you've got the widgets project well developed, and now you've been asked to
port it to SQLite. Fundamentally, that means porting all of your deploy,
revert, and verify scripts. The simplest way to organize files for this
configuration is with top-level directories for each engine. First, let's move
the existing PostgreSQL stuff to a subdirectory.

  > mkdir pg
  > mv deploy revert verify sqitch.plan pg
  > ls  pg  
  deploy/ revert/ sqitch.plan verify/

Now we need to tell Sqitch where things are. To create an engine-specific
configuration, use the L<C<engine>|sqitch-engine> command's C<add> action:

  sqitch engine add pg --top-dir pg

The C<add> action adds the C<pg> engine to the configuration, setting the top
directory to our newly-created C<pg> directory. The configuration looks like
this (with comments removed for clarity):

  [core]
    engine = pg
  [engine "pg"]
    target = db:pg:
    top_dir = pg

Curious about all the other settings for the engine? Let C<sqitch engine show>
show you:

  > sqitch engine show pg
  * pg
      Target:        db:pg:
      Registry:      sqitch
      Client:        psql
      Top Directory: pg
      Plan File:     pg/sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      Reworked Script Directories:
        Reworked:    pg
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      No Variables

The C<show> action nicely presents the result of the fully-evaluated
configuration, even though only the top directory and client have been set.
Nice, right?

Now, to add the SQLite support. There are two basic ways to go about it. We'll
start with the more obvious one.

=head2 Separate Plans

The first approach is to create an entirely independent SQLite project with
its own plan and scripts. This is I<almost> like starting from scratch: just
create a new directory and add the Sqitch engine using it for its top
directory: add initialize it as a new Sqitch project:

  > sqitch engine add sqlite --top-dir sqlite
  Created sqlite/
  Created sqlite/sqitch.plan
  Created sqlite/deploy/
  Created sqlite/revert/
  Created sqlite/verify/

Note the creation of a new F<sqlite/sqitch.conf> file. It will have copied the
project name and URI from the existing plan file. The SQLite configuration is
now added to the configuration file:

  > sqitch engine show sqlite
  * sqlite
      Target:        db:sqlite:
      Registry:      sqitch
      Client:        sqlite3
      Top Directory: sqlite
      Plan File:     sqlite/sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      Reworked Script Directories:
        Reworked:    sqlite
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      No Variables

Good, everything's in the right place. Start adding changes to the SQLite plan
by passing the engine name to the C<add> command:

  > sqitch add users sqlite -m 'Creates users table.'
  Created sqlite/deploy/users.sql
  Created sqlite/revert/users.sql
  Created sqlite/verify/users.sql
  Added "users" to sqlite/sqitch.plan

Pass C<pg> when adding PostgreSQL changes, or omit it, in which case Sqitch
will fall back on the default engine, defined by the C<core.engine> variable
set when we created the PostgreSQL project. Want to add a change with the same
name to both engines? Simply pass them both, or use the C<--all> option:

  > sqitch add users --all -m 'Creates users table.'
  Created pg/deploy/users.sql
  Created pg/revert/users.sql
  Created pg/test/users.sql
  Created pg/verify/users.sql
  Added "users" to pg/sqitch.plan
  Created sqlite/deploy/users.sql
  Created sqlite/revert/users.sql
  Created sqlite/test/users.sql
  Created sqlite/verify/users.sql
  Added "users" to sqlite/sqitch.plan

=head2 Shared Plan

The other approach is to have both the PostgreSQL and the SQLite projects
share the same plan. In that case, we should move the plan file out of the
PostgreSQL directory:

  > mv pg/sqitch.plan .
  > sqitch engine alter pg --plan-file sqitch.plan
  > sqitch engine show pg
  * pg
      Target:        db:pg:
      Registry:      sqitch
      Client:        psql
      Top Directory: pg
      Plan File:     sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      Reworked Script Directories:
        Reworked:    pg
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      No Variables

Good, it's now using F<./sqitch.plan>. Now let's start the SQLite project.
Since we're going to use the same plan, we'll need to port all the scripts
from PostgreSQL. Let's just copy them, and then configure the SQLite engine to
use the shared plan file:

  > cp -rf pg sqlite
  > sqitch engine add sqlite --plan-file sqitch.plan --top-dir sqlite
  > sqitch engine show sqlite
  * sqlite
      Target:           db:sqlite:
      Registry:         sqitch
      Client:           sqlite3
      Top Directory:    sqlite
      Plan File:        sqitch.plan
      Extension:        sql
      Script Directories:
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      Reworked Script Directories:
        Reworked:    sqlite
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      No Variables

Looks good! Now port all the scripts in the F<sqlite> directory from
PostgreSQL to SQLite and you're ready to go.

Later, when you want to add a new change to both projects, just pass the
C<--all> option to the C<add> command:

  > sqitch add users --all -n 'Creates users table.'
  Created pg/deploy/users.sql
  Created pg/revert/users.sql
  Created pg/verify/users.sql
  Created sqlite/deploy/users.sql
  Created sqlite/revert/users.sql
  Created sqlite/verify/users.sql
  Added "users" to sqitch.plan

This option also works for the C<tag>, C<rework>, and C<bundle> commands. If
you know you always want to act on all plans, set the C<all> configuration
variable for each command:

  sqitch config --bool add.all 1
  sqitch config --bool tag.all 1
  sqitch config --bool rework.all 1
  sqitch config --bool bundle.all 1

=head2 Database Interactions

With either of these two approaches, you can manage database interactions by
passing an engine name or a L<database URI|https://github.com/libwww-perl/uri-db>
to the database commands. For example, to deploy to a PostgreSQL database to
the default PostgreSQL database:

  sqitch deploy pg

You usually won't want to use the default database in production, though.
Here's how to deploy to a PostgreSQL database named "widgets" on host
C<db.example.com>:

  sqitch deploy db:pg://db.example.com/widgets

Sqitch is smart enough to pick out the proper engine from the URI. If you pass
a C<db:pg:> URI, rest assured that Sqitch won't try to deploy the SQLite
changes. Use a C<db:sqlite:> URI to interact with an SQLite database:

  sqitch log db:sqlite:/var/db/widgets.db

The commands that take engine and target URI arguments include:

=over

=item * L<C<status>|sqitch-status>

=item * L<C<log>|sqitch-log>

=item * L<C<deploy>|sqitch-deploy>

=item * L<C<revert>|sqitch-revert>

=item * L<C<rebase>|sqitch-rebase>

=item * L<C<checkout>|sqitch-checkout>

=item * L<C<verify>|sqitch-verify>

=item * L<C<verify>|sqitch-upgrade>

=back

=head1 Target Configuration

Great, now we can easily manage changes for multiple database engines. But
what about multiple databases for the same engine? For example, you might want
to deploy your database to two hosts in a primary/standby configuration. To
make things as simple as possible for your IT organization, set up named
targets for those servers:

  > sqitch target add prod-primary db:pg://sqitch@db1.example.com/widgets
  > sqitch target add prod-standby db:pg://sqitch@db2.example.com/widgets

Targets inherit configuration from engines, based on the engine specified in
the URI. Thus the configuration all comes together:

  > sqitch target show prod-primary prod-standby
  * prod-primary
      URI:           db:pg://sqitch@db1.example.com/widgets
      Registry:      sqitch
      Client:        psql
      Top Directory: pg
      Plan File:     sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      Reworked Script Directories:
        Reworked:    pg
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      No Variables
  * prod-standby
      URI:           db:pg://sqitch@db2.example.com/widgets
      Registry:      sqitch
      Client:        psql
      Top Directory: pg
      Plan File:     sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      Reworked Script Directories:
        Reworked:    pg
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      No Variables

Note the use of the shared plan and the F<pg> directory for scripts. We can
add a target for our SQLite database, too. Maybe it's used for development?

  > sqitch target add dev-sqlite db:sqlite:/var/db/widgets_dev.db
  > sqitch target show dev-sqlite
  * dev-sqlite
      URI:           db:sqlite:/var/db/widgets_dev.db
      Registry:      sqitch
      Client:        sqlite3
      Top Directory: sqlite
      Plan File:     sqitch.plan
      Extension:     sql
      Script Directories:
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      Reworked Script Directories:
        Reworked:    sqlite
        Deploy:      sqlite/deploy
        Revert:      sqlite/revert
        Verify:      sqlite/verify
      No Variables

Now deploying any of these databases is as simple as specifying the target
name when executing the L<C<deploy>|sqitch-deploy> command (assuming the
C<sqitch> user is configured to authenticate to PostgreSQL without prompting
for a password):

  > sqitch deploy prod-primary
  > sqitch deploy prod-standby

Want them all? Just query the targets and pass each in turn:

  for target in `sqitch target | grep prod-`; do
      sqitch deploy $target
  done

The commands that accept a target name are identical to those that take
an engine name or target URI, as described in L</Database Interactions>.

=head3 Different Target, Different Plan

What about a project that manages different -- but related -- schemas on the
same engine? For example, say you have two plans for PostgreSQL, one for a
canonical data store, and one for a read-only copy that will have a subset of
data replicated to it. Maybe your billing database just needs an up-to-date
copy of the C<customers> and C<users> tables.

Targets can help us here, too. Just create the new plan file. It might use
some of the same change scripts as the canonical plan, or its own scripts, or
some of each. Just be sure all of its scripts are in the same top directory.
Then add targets for the specific servers and plans:

  > sqitch target add prod-primary db:pg://db1.example.com/widgets
  > sqitch target add prod-billing db:pg://cpa.example.com/billing --plan-file target.plan
  > sqitch target show prod-billing
  * prod-billing
      URI:           db:pg://cpa.example.com/billing
      Registry:      sqitch
      Client:        psql
      Top Directory: pg
      Plan File:     target.plan
      Extension:     sql
      Script Directories:
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      Reworked Script Directories:
        Reworked:    pg
        Deploy:      pg/deploy
        Revert:      pg/revert
        Verify:      pg/verify
      No Variables

Now, any management of the C<prod-billing> target will use the F<target.plan>
plan file. Want to add changes to that plan? specify the plan file. Here's
an example that re-uses the existing change scripts:

  > sqitch add users target.plan -n 'Creates users table.'
  Skipped pg/deploy/users.sql: already exists
  Skipped pg/revert/users.sql: already exists
  Skipped pg/test/users.sql: already exists
  Skipped pg/verify/users.sql: already exists
  Added "users" to target.plan

=head1 Overworked

Say you've been working on your project for some time, and now you have a slew
of changes you've L<reworked|sqitch-rework>. (You really only do that with
procedures and views, right? Because it's silly to use for C<ALTER>
statements; just add new changes in those cases.) As a result, your deploy,
revert, and verify directories are full of files representing older versions
of the changes, all containing the C<@> symbol, and they're starting to get in
the way (in general you'll never modify them). Here's an example adapted from
a real project:

  > find pg -name '*@*'
  pg/deploy/extensions@v2.9.0.sql
  pg/deploy/jobs/func_enabler@v2.6.1.sql
  pg/deploy/stem/func_check_all_widgets@v2.11.0.sql
  pg/deploy/stem/func_check_all_widgets@v2.12.2.sql
  pg/deploy/stem/func_check_all_widgets@v2.12.3.sql
  pg/deploy/crank/func_update_jobs@v2.12.0.sql
  pg/deploy/crank/func_update_jobs@v2.8.0.sql
  pg/deploy/utility/func_get_sleepercell@v2.9.0.sql
  pg/deploy/utility/func_update_connection@v2.10.0.sql
  pg/deploy/utility/func_update_connection@v2.10.1.sql
  pg/deploy/utility/func_update_connection@v2.11.0.sql
  pg/revert/extensions@v2.9.0.sql
  pg/revert/jobs/func_enabler@v2.6.1.sql
  pg/revert/stem/func_check_all_widgets@v2.11.0.sql
  pg/revert/stem/func_check_all_widgets@v2.12.2.sql
  pg/revert/stem/func_check_all_widgets@v2.12.3.sql
  pg/revert/crank/func_update_jobs@v2.12.0.sql
  pg/revert/crank/func_update_jobs@v2.8.0.sql
  pg/revert/utility/func_get_sleepercell@v2.9.0.sql
  pg/revert/utility/func_update_connection@v2.10.0.sql
  pg/revert/utility/func_update_connection@v2.10.1.sql
  pg/revert/utility/func_update_connection@v2.11.0.sql
  pg/verify/extensions@v2.9.0.sql
  pg/verify/jobs/func_enabler@v2.6.1.sql
  pg/verify/stem/func_check_all_widgets@v2.11.0.sql
  pg/verify/stem/func_check_all_widgets@v2.12.2.sql
  pg/verify/stem/func_check_all_widgets@v2.12.3.sql
  pg/verify/crank/func_update_jobs@v2.12.0.sql
  pg/verify/crank/func_update_jobs@v2.8.0.sql
  pg/verify/utility/func_get_sleepercell@v2.9.0.sql
  pg/verify/utility/func_update_connection@v2.10.0.sql
  pg/verify/utility/func_update_connection@v2.10.1.sql
  pg/verify/utility/func_update_connection@v2.11.0.sql

Ugh. Wouldn't it be nice to move them out of the way? Of course it would! So
let's do that. We want all of the PostgreSQL engine's reworked scripts all to
go into to a new directory named "reworked", so tell Sqitch where to find
them:

  > sqitch engine alter pg --dir reworked=pg/reworked
  Created pg/reworked/deploy/
  Created pg/reworked/revert/
  Created pg/reworked/verify/

Great, it created the new directories. Note that if you wanted the directories
to have different names or locations, you can use the C<reworked_deploy>,
C<reworked_revert>, and C<reworked_verify> options.

Now all we have to do is move the files:

  cd pg
  for file in `find . -name '*@*'`
  do
      mkdir -p reworked/`dirname $file`
      mv $file reworked/`dirname $file`
  done
  cd ..

Now all the reworked deploy files are in F<pg/reworked/deploy>, the reworked
revert files are in F<pg/reworked/revert>, and the reworked verify files are
in F<pg/reworked/verify>. And you're good to go! From here on in Sqitch always
knows to find the reworked scripts when doing a L<deploy|sqitch-deploy>,
L<revert|sqitch-revert>, or L<bundle|sqitch-bundle>. And meanwhile, they're
tucked out of the way, less likely to break your brain or your IDE.

=head1 Other Options

You can see by the output of the L<C<init>|sqitch-init>,
L<C<engine>|sqitch-engine>, and L<C<target>|sqitch-target> commands that there
are quite a few other properties that can be set on a per-engine or per-target
database. To determine the value of each, Sqitch looks at a combination of
command-line options and configuration variables. Here's a complete list,
including specification of their values and how to set them.

=over

=item C<target>

The target database. May be a L<database URI|https://github.com/libwww-perl/uri-db> or
a named target managed by the L<C<target>|sqitch-target> commands. On each run,
its value will be determined by examining each of the following in turn:

=over

=item Command target argument or option

  sqitch deploy $target
  sqitch revert --target $target

=item C<$SQITCH_TARGET> environment variable

  env SQITCH_TARGET=$target sqitch deploy
  env SQITCH_TARGET=$target sqitch revert

=item C<engine.$engine.target>

  sqitch init $project --engine $engine --target $target
  sqitch engine add $engine --target $target
  sqitch engine alter $engine --target target

=item C<core.target>

  sqitch config core.target $target

=back

=item C<uri>

The L<database URI|https://github.com/libwww-perl/uri-db> to which to connect. May
only be specified as a target argument or via a named target:

=over

=item Command target argument or option

  sqitch deploy $uri
  sqitch revert --target $uri

=item C<$SQITCH_TARGET> environment variable

  env SQITCH_TARGET=$uri sqitch deploy
  env SQITCH_TARGET=$uri sqitch revert

=item C<target.$target.uri>

  sqitch init $project --engine $engine --target $uri
  sqitch target add $target --uri $uri
  sqitch target alter $target --uri $uri

=back

=item C<client>

The path to the engine client. The default is engine- and OS-specific, which
will generally work for clients in the path. If you need a custom client, you
can specify it via the following:

=over

=item C<--client>

  sqitch deploy --client $client

=item C<target.$target.client>

  sqitch target add $target --client $client
  sqitch target alter $target --client $client
  sqitch config --user target.$target.client $client

=item C<engine.$engine.client>

  sqitch init $project --engine $engine --client client
  sqitch engine add $engine --client $client
  sqitch engine alter $engine --client $client
  sqitch config --user engine.$engine.client $client

=item C<core.client>

  sqitch config core.client $client
  sqitch config --user core.client $client

=back

=item C<registry>

The name of the Sqitch registry schema or database. The default is C<sqitch>,
which should work for most uses. If you need a custom registry, specify it via
the following:

=over

=item C<--registry>

  sqitch deploy --registry $registry

=item C<target.$target.registry>

  sqitch target add $target --registry $registry
  sqitch target alter $target --registry $registry

=item C<engine.$engine.registry>

  sqitch init $project --engine $engine --registry $registry
  sqitch engine add $engine --registry $registry
  sqitch engine alter $engine --registry $registry

=item C<core.registry>

  sqitch config core.registry $registry

=back

=item C<top_dir>

The directory in which project files an subdirectories can be found, including
the plan file and script directories. The default is the current directory. If
you need a custom directory, specify it via the following:

=over

=item C<target.$target.top_dir>

  sqitch target add $target --top-dir $top_dir
  sqitch target alter $target --top-dir $top_dir

=item C<engine.$engine.top_dir>

  sqitch engine add $engine --top-dir $top_dir
  sqitch engine alter $engine --top-dir $top_dir

=item C<core.top_dir>

  sqitch init $project --top-dir $top_dir
  sqitch config core.top_dir $top_dir

=back

=item C<plan_file>

The project deployment plan file, which defaults to F<C<$top_dir/sqitch.plan>>.
If you need a different file, specify it via the following:

=over

=item C<--plan-file>

=item C<-f>

  sqitch $command --plan-file $plan_file

=item C<target.$target.plan_file>

  sqitch target add $target --plan-file $plan_file
  sqitch target alter $target --plan-file $plan_file

=item C<engine.$engine.plan_file>

  sqitch engine add $engine --plan-file $plan_file
  sqitch engine alter $engine --plan-file $plan_file

=item C<core.plan_file>

  sqitch init $project --plan-file $plan_file
  sqitch config core.plan_file $plan_file

=back

=item C<extension>

The file name extension to append to change names for change script file
names. Defaults to C<sql>. If you need a custom extension, specify it via the
following:

=over

=item C<target.$target.extension>

  sqitch target add $target --extension $extension
  sqitch target alter $target --extension $extension

=item C<engine.$engine.extension>

  sqitch engine add $engine --extension $extension
  sqitch engine alter $engine --extension $extension

=item C<core.extension>

  sqitch init $project --extension $extension
  sqitch config core.extension $extension

=back

=item C<variables>

Database client variables. 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>.
To set variables, specify them via the following:

=over

=item Command variable option

  sqitch deploy --set $key=$val -s $key2=$val2
  sqitch revert --set $key=$val -s $key2=$val2
  sqitch verify --set $key=$val -s $key2=$val2
  sqitch rework --set $key=$val -s $key2=$val2
  sqitch rework --set-deploy $key=$val --set-revert $key=$val
  sqitch checkout --set $key=$val -s $key2=$val2
  sqitch checkout --set-deploy $key=$val --set-revert $key=$val

=item C<target.$target.variables>

  sqitch target add $target --set $key=$val -s $key2=$val2
  sqitch target alter $target --set $key=$val -s $key2=$val2

=item C<engine.$engine.variables>

  sqitch engine add $engine --set $key=$val -s $key2=$val2
  sqitch engine alter $engine --set $key=$val -s $key2=$val2

=item C<$command.variables>

  sqitch config deploy.variables.$key $val
  sqitch config revert.variables.$key $val
  sqitch config verify.variables.$key $val

=item C<core.variables>

  sqitch init $project --set $key=$val -s $key2=$val2
  sqitch config core.variables.$key $val
  sqitch config core.variables.$key2 $val2

=back

=item C<deploy_dir>

The directory in which project deploy scripts can be found. Defaults to
F<C<$top_dir/deploy>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.deploy_dir>

  sqitch target add $target --dir deploy=$deploy_dir
  sqitch target alter $target --dir deploy=$deploy_dir

=item C<engine.$engine.deploy_dir>

  sqitch engine add $engine --dir deploy=$deploy_dir
  sqitch engine alter --dir deploy=$deploy_dir

=item C<core.deploy_dir>

  sqitch init $project --dir deploy=$deploy_dir
  sqitch config core.deploy_dir $deploy_dir

=back

=item C<revert_dir>

=item F<C<$top_dir/deploy>>


The directory in which project revert scripts can be found. Defaults to
F<C<$top_dir/revert>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.revert_dir>

  sqitch target add $target --dir revert=$revert_dir
  sqitch target alter $target --dir revert=$revert_dir

=item C<engine.$engine.revert_dir>

  sqitch engine add $engine --dir revert=$revert_dir
  sqitch engine alter --dir revert=$revert_dir

=item C<core.revert_dir>

  sqitch init $project --dir revert=$revert_dir
  sqitch config core.revert_dir $revert_dir

=back

=item C<verify_dir>

The directory in which project verify scripts can be found. Defaults to
F<C<$top_dir/verify>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.verify_dir>

  sqitch target add $target --dir verify=$verify_dir
  sqitch target alter $target --dir verify=$verify_dir

=item C<engine.$engine.verify_dir>

  sqitch engine add $engine --dir verify=$verify_dir
  sqitch engine alter $engine --dir verify=$verify_dir

=item C<core.verify_dir>

  sqitch init $project --dir verify=$verify_dir
  sqitch config core.verify_dir $verify_dir

=back

=item C<reworked_dir>

The directory in which subdirectories for reworked scripts can be found.
Defaults to F<C<$top_dir>>. If you need a different directory, specify it via
the following:

=over

=item C<target.$target.reworked_dir>

  sqitch target add $target --dir reworked=$reworked_dir
  sqitch target alter $target --dir reworked=$reworked_dir

=item C<engine.$engine.reworked_dir>

  sqitch engine add $engine --dir reworked=$reworked_dir
  sqitch engine alter $engine --dir reworked=$reworked_dir

=item C<core.reworked_dir>

  sqitch init $project --dir reworked=$reworked_dir
  sqitch config core.reworked_dir $reworked_dir

=back

=item C<reworked_deploy_dir>

The directory in which project deploy scripts can be found. Defaults to
F<C<reworked_dir/deploy>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.reworked_deploy_dir>

  sqitch target add $target --dir deploy=$reworked_deploy_dir
  sqitch target alter $target --dir deploy=$reworked_deploy_dir

=item C<engine.$engine.reworked_deploy_dir>

  sqitch engine add $engine --dir deploy=$reworked_deploy_dir
  sqitch engine alter --dir deploy=$reworked_deploy_dir

=item C<core.reworked_deploy_dir>

  sqitch init $project --dir deploy=$reworked_deploy_dir
  sqitch config core.reworked_deploy_dir $reworked_deploy_dir

=back

=item C<reworked_revert_dir>

The directory in which project revert scripts can be found. Defaults to
F<C<reworked_dir/revert>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.reworked_revert_dir>

  sqitch target add $target --dir revert=$reworked_revert_dir
  sqitch target alter $target --dir revert=$reworked_revert_dir

=item C<engine.$engine.reworked_revert_dir>

  sqitch engine add $engine --dir revert=$reworked_revert_dir
  sqitch engine alter --dir revert=$reworked_revert_dir

=item C<core.reworked_revert_dir>

  sqitch init $project --dir revert=$reworked_revert_dir
  sqitch config core.reworked_revert_dir $reworked_revert_dir

=back

=item C<reworked_verify_dir>

The directory in which project verify scripts can be found. Defaults to
F<C<reworked_dir/verify>>. If you need a different directory, specify it via the
following:

=over

=item C<target.$target.reworked_verify_dir>

  sqitch target add $target --dir verify=$reworked_verify_dir
  sqitch target alter $target --dir verify=$reworked_verify_dir

=item C<engine.$engine.reworked_verify_dir>

  sqitch engine add $engine --dir verify=$reworked_verify_dir
  sqitch engine alter $engine --dir verify=$reworked_verify_dir

=item C<core.reworked_verify_dir>

  sqitch init $project --dir verify=$reworked_verify_dir
  sqitch config core.reworked_verify_dir $reworked_verify_dir

=back

=back

=head1 See Also

=over

=item * L<sqitch-init>

=item * L<sqitch-target>

=item * L<sqitch-engine>

=item * L<sqitch-config>

=back

=head1 Sqitch

Part of the L<sqitch> suite.