File Coverage

blib/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/Deprecated.pm
Criterion Covered Total %
statement 13 21 61.9
branch n/a
condition n/a
subroutine 4 6 66.6
pod n/a
total 17 27 62.9


line stmt bran cond sub pod time code
1             package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated;
2             $DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated::VERSION = '0.002231';
3 2     2   150919 use Moose;
  2         373903  
  2         15  
4              
5             # ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
6              
7 2     2   14013 use File::Spec::Functions;
  2         1603  
  2         779  
8              
9             extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator';
10              
11             sub _ddl_schema_consume_filenames {
12 2     2   7 my ($self, $type, $version) = @_;
13 2         12 return [$self->_ddl_schema_produce_filename($type, $version)]
14             }
15              
16             sub _ddl_schema_produce_filename {
17 7     7   33 my ($self, $type, $version) = @_;
18 7         313 my $filename = ref $self->schema;
19 7         38 $filename =~ s/::/-/g;
20              
21 7         293 $filename = catfile(
22             $self->script_directory, "$filename-$version-$type.sql"
23             );
24              
25 7         44 return $filename;
26             }
27              
28             sub _ddl_schema_up_produce_filename {
29 0     0     my ($self, $type, $versions, $dir) = @_;
30 0           my $filename = ref $self->schema;
31 0           $filename =~ s/::/-/g;
32              
33             $filename = catfile(
34 0           $self->script_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql"
  0            
35             );
36              
37 0           return $filename;
38             }
39              
40             sub _ddl_schema_up_consume_filenames {
41 0     0     my ($self, $type, $versions) = @_;
42 0           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             =pod
54              
55             =head1 NAME
56              
57             DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated - (DEPRECATED) Use this if you are stuck in the past
58              
59             =head1 DESCRIPTION
60              
61             All this module does is override a few parts of
62             L<DBIx::Class::DeployMethd::SQL::Translator> so that the files generated with
63             L<DBIx::Class::Schema::Versioned> will work with this out of the box.
64              
65             =head1 DEPRECATED
66              
67             I begrudgingly made this module (and other related modules) to keep porting
68             from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes
69             to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
70             but I will not add any new features to it.
71              
72             Once I hit major version 1 usage of this module will emit a warning.
73             On version 2 it will be removed entirely.
74              
75             =head1 THIS SUCKS
76              
77             Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only
78             use a single .sql file for migrations, it has no .pl support. You should
79             totally switch! Here's how:
80              
81             my $init_part = ref $schema;
82             $init_part =~ s/::/-/g;
83             opendir my $dh, 'sql';
84             for (readdir $dh) {
85             if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) {
86             if (defined $3) {
87             cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]);
88             } else {
89             cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1);
90             }
91             }
92             }
93              
94             =head1 OVERRIDDEN METHODS
95              
96             =over
97              
98             =item *
99              
100             L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_consume_filenames>
101              
102             =item *
103              
104             L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_produce_filename>
105              
106             =item *
107              
108             L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_produce_filename>
109              
110             =item *
111              
112             L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_consume_filenames>
113              
114             =back
115              
116             =head1 SEE ALSO
117              
118             This class is an implementation of
119             L<DBIx::Class::DeploymentHandler::HandlesDeploy>. Pretty much all the
120             documentation is there.
121              
122             =head1 AUTHOR
123              
124             Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128             This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.
129              
130             This is free software; you can redistribute it and/or modify it under
131             the same terms as the Perl 5 programming language system itself.
132              
133             =cut