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