Commit | Line | Data |
3c1b5ee8 |
1 | package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated; |
2 | use Moose; |
3 | use Method::Signatures::Simple; |
4 | |
42c2fec3 |
5 | use File::Spec::Functions; |
6 | |
3c1b5ee8 |
7 | extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', |
8 | |
42c2fec3 |
9 | method _ddl_schema_consume_filenames($type, $version) { |
3885a58b |
10 | return [$self->_ddl_schema_produce_filename($type, $version)] |
42c2fec3 |
11 | } |
12 | |
13 | method _ddl_schema_produce_filename($type, $version) { |
3c1b5ee8 |
14 | my $filename = ref $self->schema; |
15 | $filename =~ s/::/-/g; |
16 | |
42c2fec3 |
17 | $filename = catfile( |
18 | $self->upgrade_directory, "$filename-$version-$type.sql" |
3c1b5ee8 |
19 | ); |
20 | |
42c2fec3 |
21 | return $filename; |
3c1b5ee8 |
22 | } |
23 | |
42c2fec3 |
24 | method _ddl_schema_up_produce_filename($type, $versions, $dir) { |
3c1b5ee8 |
25 | my $filename = ref $self->schema; |
26 | $filename =~ s/::/-/g; |
27 | |
42c2fec3 |
28 | $filename = catfile( |
29 | $self->upgrade_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql" |
3c1b5ee8 |
30 | ); |
31 | |
42c2fec3 |
32 | return $filename; |
3c1b5ee8 |
33 | } |
34 | |
42c2fec3 |
35 | method _ddl_schema_up_consume_filenames($type, $versions) { |
3885a58b |
36 | return [$self->_ddl_schema_up_produce_filename($type, $versions)] |
42c2fec3 |
37 | } |
38 | |
39 | __PACKAGE__->meta->make_immutable; |
40 | |
3c1b5ee8 |
41 | 1; |
3885a58b |
42 | |
43 | __END__ |
44 | |
45 | =head1 THIS SUCKS |
46 | |
47 | Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only |
48 | use a single .sql file for migrations, it has no .pl support. You should |
49 | totally switch! Here's how: |
50 | |
51 | my $init_part = ref $schema; |
52 | $init_part =~ s/::/-/g; |
53 | opendir my $dh, 'sql'; |
54 | for (readdir $dh) { |
55 | if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) { |
56 | if (defined $3) { |
57 | cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]); |
58 | } else { |
59 | cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1); |
60 | } |
61 | } |
62 | } |
63 | |
64 | vim: ts=2 sw=2 expandtab |