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