polish THIS SUCKS in main pod
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / DeployMethod / SQL / Translator / Deprecated.pm
CommitLineData
3c1b5ee8 1package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated;
2use Moose;
9deabd1f 3
4# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
5
3c1b5ee8 6use Method::Signatures::Simple;
7
42c2fec3 8use File::Spec::Functions;
9
3c1b5ee8 10extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator',
11
42c2fec3 12method _ddl_schema_consume_filenames($type, $version) {
3885a58b 13 return [$self->_ddl_schema_produce_filename($type, $version)]
42c2fec3 14}
15
16method _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 27method _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 38method _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 441;
3885a58b 45
e52174e3 46# vim: ts=2 sw=2 expandtab
47
3885a58b 48__END__
49
50=head1 THIS SUCKS
51
52Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only
53use a single .sql file for migrations, it has no .pl support. You should
54totally switch! Here's how:
55
56 my $init_part = ref $schema;
57 $init_part =~ s/::/-/g;
58 opendir my $dh, 'sql';
59 for (readdir $dh) {
60 if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) {
61 if (defined $3) {
62 cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]);
63 } else {
64 cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1);
65 }
66 }
67 }
68