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