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