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