tiny bits of cleanup
[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
a65184c8 35=head1 SYNOPSIS
e9c19a98 36
37 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
38 my $s = My::Schema->connect(...);
39
40 my $dh = DH->new({
41 schema => $s,
42 databases => 'SQLite',
43 sqltargs => { add_drop_table => 0 },
44 });
45
46 $dh->prepare_install;
47
48 $dh->install;
49
50or for upgrades:
51
52 use aliased 'DBIx::Class::DeploymentHandler' => 'DH';
53 my $s = My::Schema->connect(...);
54
55 my $dh = DH->new({
56 schema => $s,
57 databases => 'SQLite',
58 sqltargs => { add_drop_table => 0 },
59 });
60
61 $dh->prepare_upgrade(1, 2);
62
63 $dh->upgrade;
64
65=head1 DESCRIPTION
66
67C<DBIx::Class::DeploymentHandler> is, as it's name suggests, a tool for
68deploying and upgrading databases with L<DBIx::Class>. It is designed to be
69much more flexible than L<DBIx::Class::Schema::Versioned>, hence the use of
70L<Moose> and lots of roles.
71
72C<DBIx::Class::DeploymentHandler> itself is just a recommended set of roles
73that we think will not only work well for everyone, but will also yeild the
74best overall mileage. Each role it uses has it's own nuances and
75documentation, so I won't describe all of them here, but here are a few of the
76major benefits over how L<DBIx::Class::Schema::Versioned> worked (and
77L<DBIx::Class::DeploymentHandler::Deprecated> tries to maintain compatibility
78with):
79
80=over
81
e9c19a98 82=item *
83
84Downgrades in addition to upgrades.
85
86=item *
87
88Multiple sql files files per upgrade/downgrade/install.
89
90=item *
91
92Perl scripts allowed for upgrade/downgrade/install.
93
94=item *
95
96Just one set of files needed for upgrade, unlike before where one might need
97to generate C<factorial(scalar @versions)>, which is just silly.
98
99=item *
100
101And much, much more!
102
103=back
104
105That's really just a taste of some of the differences. Check out each role for
106all the details.
107
108=head1 WHERE IS ALL THE DOC?!
109
110C<DBIx::Class::DeploymentHandler> extends
111L<DBIx::Class::DeploymentHandler::Dad>, so that's probably the first place to
112look when you are trying to figure out how everything works.
113
114Next would be to look at all the roles that fill in the blanks that
115L<DBIx::Class::DeploymentHandler::Dad> expects to be filled. They would be
116L<DBIx::Class::DeploymentHandler::WithSqltDeployMethod>,
117L<DBIx::Class::DeploymentHandler::WithMonotonicVersions>,
118L<DBIx::Class::DeploymentHandler::WithStandardVersionStorage>, and
119L<DBIx::Class::DeploymentHandler::WithReasonableDefaults>.
120
121=method prepare_version_storage_install
122
123 $dh->prepare_version_storage_install
124
125Creates the needed C<.sql> file to install the version storage and not the rest
126of the tables
127
128=method install_version_storage
129
130 $dh->install_version_storage
131
132Install the version storage and not the rest of the tables
133
34ac0a51 134__END__
135
2eaf903b 136vim: ts=2 sw=2 expandtab