.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "DBIx::Class::DeploymentHandler 3pm"
.TH DBIx::Class::DeploymentHandler 3pm "2015-10-31" "perl v5.20.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
DBIx::Class::DeploymentHandler \- Extensible DBIx::Class deployment
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& use aliased \*(AqDBIx::Class::DeploymentHandler\*(Aq => \*(AqDH\*(Aq;
\& my $s = My::Schema\->connect(...);
\&
\& my $dh = DH\->new({
\& schema => $s,
\& databases => \*(AqSQLite\*(Aq,
\& sql_translator_args => { add_drop_table => 0 },
\& });
\&
\& $dh\->prepare_install;
\&
\& $dh\->install;
.Ve
.PP
or for upgrades:
.PP
.Vb 2
\& use aliased \*(AqDBIx::Class::DeploymentHandler\*(Aq => \*(AqDH\*(Aq;
\& my $s = My::Schema\->connect(...);
\&
\& my $dh = DH\->new({
\& schema => $s,
\& databases => \*(AqSQLite\*(Aq,
\& sql_translator_args => { add_drop_table => 0 },
\& });
\&
\& $dh\->prepare_deploy;
\& $dh\->prepare_upgrade({
\& from_version => 1,
\& to_version => 2,
\& });
\&
\& $dh\->upgrade;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR is, as its name suggests, a tool for
deploying and upgrading databases with DBIx::Class. It is designed to be
much more flexible than DBIx::Class::Schema::Versioned, hence the use of
Moose and lots of roles.
.PP
\&\f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR itself is just a recommended set of roles
that we think will not only work well for everyone, but will also yield the
best overall mileage. Each role it uses has its own nuances and
documentation, so I won't describe all of them here, but here are a few of the
major benefits over how DBIx::Class::Schema::Versioned worked (and
DBIx::Class::DeploymentHandler::Deprecated tries to maintain compatibility
with):
.IP "\(bu" 4
Downgrades in addition to upgrades.
.IP "\(bu" 4
Multiple sql files files per upgrade/downgrade/install.
.IP "\(bu" 4
Perl scripts allowed for upgrade/downgrade/install.
.IP "\(bu" 4
Just one set of files needed for upgrade, unlike before where one might need
to generate \f(CW\*(C`factorial(scalar @versions)\*(C'\fR, which is just silly.
.IP "\(bu" 4
And much, much more!
.PP
That's really just a taste of some of the differences. Check out each role for
all the details.
.SH "WHERE IS ALL THE DOC?!"
.IX Header "WHERE IS ALL THE DOC?!"
\&\f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR extends
DBIx::Class::DeploymentHandler::Dad, so that's probably the first place to
look when you are trying to figure out how everything works.
.PP
Next would be to look at all the pieces that fill in the blanks that
DBIx::Class::DeploymentHandler::Dad expects to be filled. They would be
DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator,
DBIx::Class::DeploymentHandler::VersionHandler::Monotonic,
DBIx::Class::DeploymentHandler::VersionStorage::Standard, and
DBIx::Class::DeploymentHandler::WithReasonableDefaults.
.SH "WHY IS THIS SO WEIRD"
.IX Header "WHY IS THIS SO WEIRD"
\&\f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR has a strange structure. The gist is that it
delegates to three small objects that are proxied to via interface roles that
then create the illusion of one large, monolithic object. Here is a diagram
that might help:
.PP
The nice thing about this is that we have well defined interfaces for the
objects that comprise the \f(CW\*(C`DeploymentHandler\*(C'\fR, the smaller objects can be
tested in isolation, and the smaller objects can even be swapped in easily. But
the real win is that you can subclass the \f(CW\*(C`DeploymentHandler\*(C'\fR without knowing
about the underlying delegation; you just treat it like normal Perl and write
methods that do what you want.
.SH "THIS SUCKS"
.IX Header "THIS SUCKS"
You started your project and weren't using \f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR?
Lucky for you I had you in mind when I wrote this doc.
.PP
First,
define the version
in your main schema file (maybe using \f(CW$VERSION\fR).
.PP
Then you'll want to just install the version_storage:
.PP
.Vb 2
\& my $s = My::Schema\->connect(...);
\& my $dh = DBIx::Class::DeploymentHandler\->new({ schema => $s });
\&
\& $dh\->prepare_version_storage_install;
\& $dh\->install_version_storage;
.Ve
.PP
Then set your database version:
.PP
.Vb 1
\& $dh\->add_database_version({ version => $s\->schema_version });
.Ve
.PP
Now you should be able to use \f(CW\*(C`DBIx::Class::DeploymentHandler\*(C'\fR like normal!
.SH "LOGGING"
.IX Header "LOGGING"
This is a complex tool, and because of that sometimes you'll want to see
what exactly is happening. The best way to do that is to use the built in
logging functionality. It the standard six log levels; \f(CW\*(C`fatal\*(C'\fR, \f(CW\*(C`error\*(C'\fR,
\&\f(CW\*(C`warn\*(C'\fR, \f(CW\*(C`info\*(C'\fR, \f(CW\*(C`debug\*(C'\fR, and \f(CW\*(C`trace\*(C'\fR. Most of those are pretty self
explanatory. Generally a safe level to see what all is going on is debug,
which will give you everything except for the exact \s-1SQL\s0 being run.
.PP
To enable the various logging levels all you need to do is set an environment
variables: \f(CW\*(C`DBICDH_FATAL\*(C'\fR, \f(CW\*(C`DBICDH_ERROR\*(C'\fR, \f(CW\*(C`DBICDH_WARN\*(C'\fR, \f(CW\*(C`DBICDH_INFO\*(C'\fR,
\&\f(CW\*(C`DBICDH_DEBUG\*(C'\fR, and \f(CW\*(C`DBICDH_TRACE\*(C'\fR. Each level can be set on its own,
but the default is the first three on and the last three off, and the levels
cascade, so if you turn on trace the rest will turn on automatically.
.SH "DONATIONS"
.IX Header "DONATIONS"
If you'd like to thank me for the work I've done on this module, don't give me
a donation. I spend a lot of free time creating free software, but I do it
because I love it.
.PP
Instead, consider donating to someone who might actually need it. Obviously
you should do research when donating to a charity, so don't just take my word
on this. I like Matthew 25: Ministries:
, but there are a host of other
charities that can do much more good than I will with your money.
(Third party charity info here:
.SH "METHODS"
.IX Header "METHODS"
.SS "prepare_version_storage_install"
.IX Subsection "prepare_version_storage_install"
.Vb 1
\& $dh\->prepare_version_storage_install
.Ve
.PP
Creates the needed \f(CW\*(C`.sql\*(C'\fR file to install the version storage and not the rest
of the tables
.SS "prepare_install"
.IX Subsection "prepare_install"
.Vb 1
\& $dh\->prepare_install
.Ve
.PP
First prepare all the tables to be installed and the prepare just the version
storage
.SS "install_version_storage"
.IX Subsection "install_version_storage"
.Vb 1
\& $dh\->install_version_storage
.Ve
.PP
Install the version storage and not the rest of the tables
.SH "AUTHOR"
.IX Header "AUTHOR"
Arthur Axel \*(L"fREW\*(R" Schmidt
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2015 by Arthur Axel \*(L"fREW\*(R" Schmidt.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.