fix a tiny bit of pod
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler.pm
CommitLineData
b974984a 1package DBIx::Class::DeploymentHandler;
2
a65184c8 3# ABSTRACT: Extensible DBIx::Class deployment
4
b974984a 5use Moose;
b974984a 6
c4f4d4a2 7extends 'DBIx::Class::DeploymentHandler::Dad';
41219a5d 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
973d060d 10with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod',
4a65f60b 11 'DBIx::Class::DeploymentHandler::WithMonotonicVersions',
973d060d 12 'DBIx::Class::DeploymentHandler::WithStandardVersionStorage';
41219a5d 13with 'DBIx::Class::DeploymentHandler::WithReasonableDefaults';
2e68a8e1 14
c8a2f7bd 15sub prepare_version_storage_install {
16 my $self = shift;
17
18 $self->prepare_resultsource_install(
19 $self->version_storage->version_rs->result_source
20 );
21}
22
23sub install_version_storage {
24 my $self = shift;
25
26 $self->install_resultsource(
27 $self->version_storage->version_rs->result_source
28 );
29}
30
2e68a8e1 31__PACKAGE__->meta->make_immutable;
32
b974984a 331;
61847972 34
d1ae780e 35#vim: ts=2 sw=2 expandtab
36
37__END__
38
a65184c8 39=head1 SYNOPSIS
e9c19a98 40
41 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
42 my $s = My::Schema->connect(...);
43
44 my $dh = DH->new({
45 schema => $s,
46 databases => 'SQLite',
47 sqltargs => { add_drop_table => 0 },
48 });
49
50 $dh->prepare_install;
51
52 $dh->install;
53
54or for upgrades:
55
56 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
57 my $s = My::Schema->connect(...);
58
59 my $dh = DH->new({
60 schema => $s,
61 databases => 'SQLite',
62 sqltargs => { add_drop_table => 0 },
63 });
64
65 $dh->prepare_upgrade(1, 2);
66
67 $dh->upgrade;
68
69=head1 DESCRIPTION
70
71C<DBIx::Class::DeploymentHandler> is, as it's name suggests, a tool for
72deploying and upgrading databases with L<DBIx::Class>. It is designed to be
73much more flexible than L<DBIx::Class::Schema::Versioned>, hence the use of
74L<Moose> and lots of roles.
75
76C<DBIx::Class::DeploymentHandler> itself is just a recommended set of roles
77that we think will not only work well for everyone, but will also yeild the
78best overall mileage. Each role it uses has it's own nuances and
79documentation, so I won't describe all of them here, but here are a few of the
80major benefits over how L<DBIx::Class::Schema::Versioned> worked (and
81L<DBIx::Class::DeploymentHandler::Deprecated> tries to maintain compatibility
82with):
83
84=over
85
e9c19a98 86=item *
87
88Downgrades in addition to upgrades.
89
90=item *
91
92Multiple sql files files per upgrade/downgrade/install.
93
94=item *
95
96Perl scripts allowed for upgrade/downgrade/install.
97
98=item *
99
100Just one set of files needed for upgrade, unlike before where one might need
101to generate C<factorial(scalar @versions)>, which is just silly.
102
103=item *
104
105And much, much more!
106
107=back
108
109That's really just a taste of some of the differences. Check out each role for
110all the details.
111
112=head1 WHERE IS ALL THE DOC?!
113
114C<DBIx::Class::DeploymentHandler> extends
115L<DBIx::Class::DeploymentHandler::Dad>, so that's probably the first place to
116look when you are trying to figure out how everything works.
117
118Next would be to look at all the roles that fill in the blanks that
119L<DBIx::Class::DeploymentHandler::Dad> expects to be filled. They would be
120L<DBIx::Class::DeploymentHandler::WithSqltDeployMethod>,
121L<DBIx::Class::DeploymentHandler::WithMonotonicVersions>,
122L<DBIx::Class::DeploymentHandler::WithStandardVersionStorage>, and
123L<DBIx::Class::DeploymentHandler::WithReasonableDefaults>.
124
125=method prepare_version_storage_install
126
127 $dh->prepare_version_storage_install
128
129Creates the needed C<.sql> file to install the version storage and not the rest
130of the tables
131
132=method install_version_storage
133
134 $dh->install_version_storage
135
136Install the version storage and not the rest of the tables
137
d1ae780e 138=head1 THIS SUCKS
139
140You started your project and weren't using DBICDH? FOOL! Lucky for you I had
141you in mind when I wrote this doc <3
142
143First off, you'll want to just install the version_storage:
144
145 my $s = My::Schema->connect(...);
146 my $dh = DeployHandler({ schema => $s });
147
148 $dh->prepare_version_storage_install;
149 $dh->install_version_storage;
34ac0a51 150
d1ae780e 151Then, bump your schema version, and you can use DBICDH like normal!
698944cb 152
153=head1 DONATIONS
154
155If you'd like to thank me for the work I've done on this module, don't give me
156a donation. I spend a lot of free time creating free software, but I do it
157because I love it.
158
159Instead, consider donating to someone who might actually need it. Obviously
160you should do research when donating to a charity, so don't just take my word
161on this. I like
162L<<a href="http://www.childrenssurvivalfund.org/">Children's Survival Fund</a>>,
163but there are a host of other charities that can do much more good than I will
164with your money.