Commit | Line | Data |
3c1b5ee8 |
1 | package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated; |
2 | use Moose; |
9deabd1f |
3 | |
4 | # ABSTRACT: (DEPRECATED) Use this if you are stuck in the past |
5 | |
42c2fec3 |
6 | use File::Spec::Functions; |
7 | |
ffe7229c |
8 | extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; |
3c1b5ee8 |
9 | |
ffe7229c |
10 | sub _ddl_schema_consume_filenames { |
11 | my ($self, $type, $version) = @_; |
3885a58b |
12 | return [$self->_ddl_schema_produce_filename($type, $version)] |
42c2fec3 |
13 | } |
14 | |
ffe7229c |
15 | sub _ddl_schema_produce_filename { |
16 | my ($self, $type, $version) = @_; |
3c1b5ee8 |
17 | my $filename = ref $self->schema; |
18 | $filename =~ s/::/-/g; |
19 | |
42c2fec3 |
20 | $filename = catfile( |
91adde75 |
21 | $self->script_directory, "$filename-$version-$type.sql" |
3c1b5ee8 |
22 | ); |
23 | |
42c2fec3 |
24 | return $filename; |
3c1b5ee8 |
25 | } |
26 | |
ffe7229c |
27 | sub _ddl_schema_up_produce_filename { |
28 | my ($self, $type, $versions, $dir) = @_; |
3c1b5ee8 |
29 | my $filename = ref $self->schema; |
30 | $filename =~ s/::/-/g; |
31 | |
42c2fec3 |
32 | $filename = catfile( |
91adde75 |
33 | $self->script_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql" |
3c1b5ee8 |
34 | ); |
35 | |
42c2fec3 |
36 | return $filename; |
3c1b5ee8 |
37 | } |
38 | |
ffe7229c |
39 | sub _ddl_schema_up_consume_filenames { |
40 | my ($self, $type, $versions) = @_; |
3885a58b |
41 | return [$self->_ddl_schema_up_produce_filename($type, $versions)] |
42c2fec3 |
42 | } |
43 | |
44 | __PACKAGE__->meta->make_immutable; |
45 | |
3c1b5ee8 |
46 | 1; |
3885a58b |
47 | |
e52174e3 |
48 | # vim: ts=2 sw=2 expandtab |
49 | |
3885a58b |
50 | __END__ |
51 | |
bcc72297 |
52 | =head1 DESCRIPTION |
53 | |
54 | All this module does is override a few parts of |
55 | L<DBIx::Class::DeployMethd::SQL::Translator> so that the files generated with |
56 | L<DBIx::Class::Schema::Versioned> will work with this out of the box. |
57 | |
58 | =head1 DEPRECATED |
59 | |
60 | I begrudgingly made this module (and other related modules) to keep porting |
61 | from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes |
62 | to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc, |
63 | but I will not add any new features to it. |
64 | |
65 | Once I hit major version 1 usage of this module will emit a warning. |
66 | On version 2 it will be removed entirely. |
67 | |
3885a58b |
68 | =head1 THIS SUCKS |
69 | |
70 | Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only |
71 | use a single .sql file for migrations, it has no .pl support. You should |
72 | totally switch! Here's how: |
73 | |
74 | my $init_part = ref $schema; |
75 | $init_part =~ s/::/-/g; |
76 | opendir my $dh, 'sql'; |
77 | for (readdir $dh) { |
78 | if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) { |
79 | if (defined $3) { |
80 | cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]); |
81 | } else { |
82 | cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1); |
83 | } |
84 | } |
85 | } |
86 | |
bcc72297 |
87 | =head1 OVERRIDDEN METHODS |
88 | |
89 | =over |
90 | |
91 | =item * |
92 | |
93 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_consume_filenames> |
94 | |
95 | =item * |
96 | |
97 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_produce_filename> |
98 | |
99 | =item * |
100 | |
101 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_produce_filename> |
102 | |
103 | =item * |
104 | |
105 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_consume_filenames> |
106 | |
107 | =back |
108 | |
ec167a97 |
109 | =head1 SEE ALSO |
110 | |
111 | This class is an implementation of |
112 | L<DBIx::Class::DeploymentHandler::HandlesDeploy>. Pretty much all the |
113 | documentation is there. |