App-Dest
view release on metacpan or search on metacpan
lib/App/Dest.pm view on Meta::CPAN
program, and second, the action type ("deploy", "revert", "verify").
=head1 WATCH FILE
Optionally, you can elect to use a watch file that can be committed to your
favorite revision control system. In the root directory of your project, create
a filed called "dest.watch" and list therein the directories (relative to the
root directory of the project) to watch.
If this "dest.watch" file exists in the root directory of your project, C<dest>
will add the following behavior:
During an "init" action, the C<dest.watch> file will be read to setup all
watched directories (as though you manually called the "add" action on each).
During a "status" action, C<dest> will report any differences between your
current watch list and the C<dest.watch> file.
During an "update" action, C<dest> will automatically add (as if you manually
called the "add" action) each directory in the C<dest.watch> file that is
currently not watched by C<dest> prior to executing the update action.
=head1 EXAMPLE SCENARIO
To help illustrate what C<dest> can do, consider the following example scenario.
You start a new project that requires the use of a typical database. You want to
control the schema of that database with progressively executed SQL files. You
also have data operations that require more functionality than what SQL can
provide, so you'd like to have data operations handled by progressively executed
Perl programs.
=head2 Project Initiation
You could setup your changes and C<dest> as follows (starting in your project's
root directory):
mkdir db data # create the directories
dest init # initiate dest for your project
dest add db data # add the directories to the dest watch list
dest writewatch # write the watch list (so others can init without adding)
dest status # show the current status (which is everything is OK)
=head2 Create Schema Action
The next step would probably be to create your database schema as a C<dest>
action. Actions include deploy, verify, and revert files. You can use the "make"
command to create these files for you. The command will return the list of files
created, so you can wrap the command to your favorite editor.
dest make db/schema sql # create "schema" action as ".sql" files
vi `dest list db/schema` # list the "schema" files into vi
vi `dest make db/schema sql` # the previous 2 commands as 1 command
Your deploy file will be the SQL required to create your schema. The revert file
reverts what the deploy file deploys. The verify file needs to return some
positive value if and only if the deploy action worked.
Since your local CLI shell probably doesn't know how to execute SQL files
natively, you'll likely need to create a C<dest.wrap> file.
touch db/dest.wrap && chmod u+x db/dest.wrap && vi db/dest.wrap
This file if it exists will get executed instead of the deploy, verify, and
revert files, and it will be passed the action file being executed.
=head2 Status and Deploying
Now, check the project's C<dest> status:
dest s # short for "dest status"
You should see:
ok - data
diff - db
+ db/schema
This indicates that the "schema" action exists in your code but has not been
executed on your environment. To execute, you have a couple options:
dest deploy db/schema # explicitly deploy the "schema" action
dest update # make dest do whatever status says needs to be done
If you run C<dest update> and there's nothing to do, C<dest> will happily do
nothing. If you run C<dest deploy db/schema> after having already deployed
"schema", C<dest> will complain that "schema" has already been deployed. If you
really, really want to run a deploy of "schema" again:
dest redeploy db/schema # deploy "schema" even if you already did
=head2 Changing a Deployed Action
If you discover you made a mistake in a table definition inside your "schema"
deploy action file, you could either create a second action to change that table
or change the "schema" deploy and "revdeploy" to revert the old "schema" deploy
action and deploy the new "schema" deploy action. Let's alter the deploy action
already created, then check status.
vi db/schema/deploy.sql # fix the table definition
dest status
You should see something like:
ok - data
diff - db
db/schema/deploy.sql
M db/schema/deploy.sql
This indicates that the C<schema/deploy> action is different than what was
deployed. You can revert the action and deploy it with the "revert" and "deploy"
actions, or do it in a single "revdeploy" command:
dest revert db/schema # revert old action
dest deploy db/schema # deploy new action
dest revdeploy db/schema # revert old action and deploy new action
=head2 Action with a Dependency
Now let's create a data action, a Perl program that will do things and stuff
to insert data into the database. To work, this action obviously will require
the schema action to have already been deployed.
( run in 1.388 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )