1 package DBIx::Class::DeploymentHandler;
3 # ABSTRACT: Extensible DBIx::Class deployment
7 extends 'DBIx::Class::DeploymentHandler::Dad';
8 # a single with would be better, but we can't do that
9 # see: http://rt.cpan.org/Public/Bug/Display.html?id=46347
10 with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod',
11 'DBIx::Class::DeploymentHandler::WithMonotonicVersions',
12 'DBIx::Class::DeploymentHandler::WithStandardVersionStorage';
13 with 'DBIx::Class::DeploymentHandler::WithReasonableDefaults';
15 sub prepare_version_storage_install {
18 $self->prepare_resultsource_install(
19 $self->version_storage->version_rs->result_source
23 sub install_version_storage {
26 $self->install_resultsource(
27 $self->version_storage->version_rs->result_source
31 __PACKAGE__->meta->make_immutable;
35 #vim: ts=2 sw=2 expandtab
41 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
42 my $s = My::Schema->connect(...);
46 databases => 'SQLite',
47 sqltargs => { add_drop_table => 0 },
56 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
57 my $s = My::Schema->connect(...);
61 databases => 'SQLite',
62 sqltargs => { add_drop_table => 0 },
65 $dh->prepare_upgrade(1, 2);
71 C<DBIx::Class::DeploymentHandler> is, as it's name suggests, a tool for
72 deploying and upgrading databases with L<DBIx::Class>. It is designed to be
73 much more flexible than L<DBIx::Class::Schema::Versioned>, hence the use of
74 L<Moose> and lots of roles.
76 C<DBIx::Class::DeploymentHandler> itself is just a recommended set of roles
77 that we think will not only work well for everyone, but will also yeild the
78 best overall mileage. Each role it uses has it's own nuances and
79 documentation, so I won't describe all of them here, but here are a few of the
80 major benefits over how L<DBIx::Class::Schema::Versioned> worked (and
81 L<DBIx::Class::DeploymentHandler::Deprecated> tries to maintain compatibility
88 Downgrades in addition to upgrades.
92 Multiple sql files files per upgrade/downgrade/install.
96 Perl scripts allowed for upgrade/downgrade/install.
100 Just one set of files needed for upgrade, unlike before where one might need
101 to generate C<factorial(scalar @versions)>, which is just silly.
109 That's really just a taste of some of the differences. Check out each role for
112 =head1 WHERE IS ALL THE DOC?!
114 C<DBIx::Class::DeploymentHandler> extends
115 L<DBIx::Class::DeploymentHandler::Dad>, so that's probably the first place to
116 look when you are trying to figure out how everything works.
118 Next would be to look at all the roles that fill in the blanks that
119 L<DBIx::Class::DeploymentHandler::Dad> expects to be filled. They would be
120 L<DBIx::Class::DeploymentHandler::WithSqltDeployMethod>,
121 L<DBIx::Class::DeploymentHandler::WithMonotonicVersions>,
122 L<DBIx::Class::DeploymentHandler::WithStandardVersionStorage>, and
123 L<DBIx::Class::DeploymentHandler::WithReasonableDefaults>.
125 =method prepare_version_storage_install
127 $dh->prepare_version_storage_install
129 Creates the needed C<.sql> file to install the version storage and not the rest
132 =method install_version_storage
134 $dh->install_version_storage
136 Install the version storage and not the rest of the tables
140 You started your project and weren't using C<DBIx::Class::DeploymentHandler>?
141 Lucky for you I had you in mind when I wrote this doc.
143 First off, you'll want to just install the C<version_storage>:
145 my $s = My::Schema->connect(...);
146 my $dh = DBIx::Class::DeploymentHandler({ schema => $s });
148 $dh->prepare_version_storage_install;
149 $dh->install_version_storage;
151 Then set your database version:
153 $dh->add_database_version({ version => $s->version });
155 Now you should be able to use C<DBIx::Class::DeploymentHandler> like normal!
159 If you'd like to thank me for the work I've done on this module, don't give me
160 a donation. I spend a lot of free time creating free software, but I do it
163 Instead, consider donating to someone who might actually need it. Obviously
164 you should do research when donating to a charity, so don't just take my word
165 on this. I like Children's Survival Fund:
166 L<http://www.childrenssurvivalfund.org>, but there are a host of other
167 charities that can do much more good than I will with your money.