Wrap upgrades, downgrades, and installs in a transaction
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / HandlesDeploy.pm
CommitLineData
7521a845 1package DBIx::Class::DeploymentHandler::HandlesDeploy;
2use Moose::Role;
3
9deabd1f 4# ABSTRACT: Interface for deploy methods
5
ff40cb1f 6requires 'initialize';
fc4b7602 7
91557c90 8requires 'prepare_deploy';
9requires 'deploy';
10
c8a2f7bd 11requires 'prepare_resultsource_install';
12requires 'install_resultsource';
91557c90 13
a41a04e5 14requires 'prepare_upgrade';
7d2a6974 15requires 'upgrade_single_step';
91557c90 16
17requires 'prepare_downgrade';
7d2a6974 18requires 'downgrade_single_step';
7521a845 19
1fcd4fe6 20requires 'txn_do';
21
7521a845 221;
23
37c0b85d 24# vim: ts=2 sw=2 expandtab
25
26__END__
27
ff40cb1f 28=method initialize
80ff6f6d 29
ff40cb1f 30 $dh->initialize({
be140a5f 31 version => 1,
32 storage_type => 'SQLite'
33 });
80ff6f6d 34
35Run scripts before deploying to the database
36
91557c90 37=method prepare_deploy
e3776e58 38
91557c90 39 $dh->prepare_deploy
e3776e58 40
41Generate the needed data files to install the schema to the database.
96ef97e5 42
43=method deploy
44
be140a5f 45 $dh->deploy({ version => 1 })
5228a963 46
47Deploy the schema to the database.
96ef97e5 48
49=method prepare_resultsource_install
50
be140a5f 51 $dh->prepare_resultsource_install({
52 result_source => $resultset->result_source,
53 })
96ef97e5 54
37c0b85d 55Takes a L<DBIx::Class::ResultSource> and generates a single migration file to
56create the resultsource's table.
57
96ef97e5 58=method install_resultsource
59
be140a5f 60 $dh->install_resultsource({
61 result_source => $resultset->result_source,
62 version => 1,
63 })
96ef97e5 64
37c0b85d 65Takes a L<DBIx::Class::ResultSource> and runs a single migration file to
66deploy the resultsource's table.
96ef97e5 67
68=method prepare_upgrade
69
be140a5f 70 $dh->prepare_upgrade({
71 from_version => 1,
72 to_version => 2,
73 version_set => [1, 2]
74 });
96ef97e5 75
37c0b85d 76Takes two versions and a version set. This basically is supposed to generate
77the needed C<SQL> to migrate up from the first version to the second version.
78The version set uniquely identifies the migration.
96ef97e5 79
80=method prepare_downgrade
81
be140a5f 82 $dh->prepare_downgrade({
83 from_version => 1,
84 to_version => 2,
85 version_set => [1, 2]
86 });
96ef97e5 87
37c0b85d 88Takes two versions and a version set. This basically is supposed to generate
89the needed C<SQL> to migrate down from the first version to the second version.
734ace8a 90The version set uniquely identifies the migration and should match its
37c0b85d 91respective upgrade version set.
92
96ef97e5 93=method upgrade_single_step
94
be140a5f 95 my ($ddl, $sql) = @{
96 $dh->upgrade_single_step({ version_set => $version_set })
97 ||[]}
5228a963 98
37c0b85d 99Call a single upgrade migration. Takes a version set as an argument.
100Optionally return C<< [ $ddl, $upgrade_sql ] >> where C<$ddl> is the DDL for
101that version of the schema and C<$upgrade_sql> is the SQL that was run to
102upgrade the database.
96ef97e5 103
104=method downgrade_single_step
105
5228a963 106 $dh->downgrade_single_step($version_set);
107
37c0b85d 108Call a single downgrade migration. Takes a version set as an argument.
109Optionally return C<< [ $ddl, $upgrade_sql ] >> where C<$ddl> is the DDL for
110that version of the schema and C<$upgrade_sql> is the SQL that was run to
111upgrade the database.
96ef97e5 112
1fcd4fe6 113=method txn_do
114
115 $dh->txn_do(sub { ... })
116
117Wrap the passed coderef in a transaction (if transactions are enabled.)
118
ed1721b9 119=head1 KNOWN IMPLEMENTATIONS
120
121=over
122
123=item *
124
125L<DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator>
126
127=item *
128
129L<DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated>
130
131=back
132