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