App::Sqitch::Target(3pm) | User Contributed Perl Documentation | App::Sqitch::Target(3pm) |
App::Sqitch::Target - Sqitch deployment target
my $plan = App::Sqitch::Target->new( sqitch => $sqitch, name => 'development', ); $target->engine->deploy;
App::Sqitch::Target provides collects, in one place, the engine, plan, and file locations required to carry out Sqitch commands. All commands should instantiate a target to work with the plan or database.
"new"
my $target = App::Sqitch::Target->new( sqitch => $sqitch );
Instantiates and returns an App::Sqitch::Target object. The most important parameters are "sqitch", "name", and "uri". The constructor tries really hard to figure out the proper name and URI during construction. If the "uri" parameter is passed, this is straight-forward: if no "name" is passed, "name" will be set to the stringified format of the URI (minus the password, if present).
Otherwise, when no URI is passed, the name and URI are determined by taking the following steps:
As a general rule, then, pass either a target name or URI string in the "name" parameter, and Sqitch will do its best to find all the relevant target information. And if there is no name or URI, it will try to construct a reasonable default from the command-line options or engine configuration.
All Target attributes may be passed as parameters to "new()". In addition, "new()" accepts a few non-attribute parameters that may be used to override parts of the connection URI. They are:
For example, if the the named target had its URI configured as "db:pg://fred@example.com/work", The "uri" would be set as such by:
my $target = App::Sqitch::Target->new(sqitch => $sqitch, name => 'work'); say $target->uri;
However, passing the URI parameters like this:
my $target = App::Sqitch::Target->new( sqitch => $sqitch, name => 'work', user => 'bill', port => 1212, ); say $target->uri;
Sets the URI to "db:pg://bill@example.com:1212/work".
"all_targets"
Returns a list of all the targets defined by the local Sqitch configuration file. Done by examining the configuration object to find all defined targets and engines, as well as the default "core" target. Duplicates are removed and the list returned. This method takes the same parameters as "new"; only "sqitch" is required. All other parameters will be set on all of the returned targets.
"sqitch"
my $sqitch = $target->sqitch;
Returns the App::Sqitch object that instantiated the target.
"name"
"target"
my $name = $target->name; $name = $target->target;
The name of the target. If there was no name specified, the URI will be used (minus the password, if there is one).
"uri"
my $uri = $target->uri;
The URI::db object encapsulating the database connection information.
"username"
my $username = $target->username;
Returns the target username, if any. The username is looked up from the URI.
"password"
my $password = $target->password;
Returns the target password, if any. The password is looked up from the URI or the $SQITCH_PASSWORD environment variable.
"engine"
my $engine = $target->engine;
A App::Sqitch::Engine object to use for database interactions with the target.
"registry"
my $registry = $target->registry;
The name of the registry used by the database. The value comes from one of these options, searched in this order:
"client"
my $client = $target->client;
Path to the engine command-line client. The value comes from one of these options, searched in this order:
"top_dir"
my $top_dir = $target->top_dir;
The path to the top directory of the project. This directory generally contains the plan file and subdirectories for deploy, revert, and verify scripts. The value comes from one of these options, searched in this order:
"plan_file"
my $plan_file = $target->plan_file;
The path to the plan file. The value comes from one of these options, searched in this order:
"deploy_dir"
my $deploy_dir = $target->deploy_dir;
The path to the deploy directory of the project. This directory contains all of the deploy scripts referenced by changes in the "plan_file". The value comes from one of these options, searched in this order:
"revert_dir"
my $revert_dir = $target->revert_dir;
The path to the revert directory of the project. This directory contains all of the revert scripts referenced by changes the "plan_file". The value comes from one of these options, searched in this order:
"verify_dir"
my $verify_dir = $target->verify_dir;
The path to the verify directory of the project. This directory contains all of the verify scripts referenced by changes in the "plan_file". The value comes from one of these options, searched in this order:
"reworked_dir"
my $reworked_dir = $target->reworked_dir;
The path to the reworked directory of the project. This directory contains subdirectories for reworked deploy, revert, and verify scripts. The value comes from one of these options, searched in this order:
"reworked_deploy_dir"
my $reworked_deploy_dir = $target->reworked_deploy_dir;
The path to the reworked deploy directory of the project. This directory contains all of the reworked deploy scripts referenced by changes in the "plan_file". The value comes from one of these options, searched in this order:
"reworked_revert_dir"
my $reworked_revert_dir = $target->reworked_revert_dir;
The path to the reworked revert directory of the project. This directory contains all of the reworked revert scripts referenced by changes the "plan_file". The value comes from one of these options, searched in this order:
"reworked_verify_dir"
my $reworked_verify_dir = $target->reworked_verify_dir;
The path to the reworked verify directory of the project. This directory contains all of the reworked verify scripts referenced by changes in the "plan_file". The value comes from one of these options, searched in this order:
"extension"
my $extension = $target->extension;
The file name extension to append to change names to create script file names. The value comes from one of these options, searched in this order:
"variables"
my $variables = $target->variables;
The database variables to use in change scripts. The value are merged from these options, in this order:
The "core.variables" configuration is not read, because command-specific configurations, such as "deploy.variables" and "revert.variables" take priority. The command themselves therefore pass them to the engine in the proper priority order.
"engine_key"
my $key = $target->engine_key;
The key defining which engine to use. This value defines the class loaded by "engine". Convenience method for "$target->uri->canonical_engine".
"dsn"
my $dsn = $target->dsn;
The DSN to use when connecting to the target via the DBI. Convenience method for "$target->uri->dbi_dsn".
"username"
my $username = $target->username;
The username to use when connecting to the target via the DBI. Convenience method for "$target->uri->user".
"password"
my $password = $target->password;
The password to use when connecting to the target via the DBI. Convenience method for "$target->uri->password".
David E. Wheeler <david@justatheory.com>
Copyright (c) 2012-2018 iovation Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2019-02-15 | perl v5.28.1 |