File: Deprecated.pm

package info (click to toggle)
libdbix-class-deploymenthandler-perl 0.002233-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 540 kB
  • sloc: perl: 4,139; makefile: 2
file content (133 lines) | stat: -rw-r--r-- 3,415 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated;
$DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated::VERSION = '0.002233';
use Moose;

# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past

use File::Spec::Functions;

extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator';

sub _ddl_schema_consume_filenames {
  my ($self, $type, $version) = @_;
  return [$self->_ddl_schema_produce_filename($type, $version)]
}

sub _ddl_schema_produce_filename {
  my ($self, $type, $version) = @_;
  my $filename = ref $self->schema;
  $filename =~ s/::/-/g;

  $filename = catfile(
    $self->script_directory, "$filename-$version-$type.sql"
  );

  return $filename;
}

sub _ddl_schema_up_produce_filename {
  my ($self, $type, $versions, $dir) = @_;
  my $filename = ref $self->schema;
  $filename =~ s/::/-/g;

  $filename = catfile(
    $self->script_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql"
  );

  return $filename;
}

sub _ddl_schema_up_consume_filenames {
  my ($self, $type, $versions) = @_;
  return [$self->_ddl_schema_up_produce_filename($type, $versions)]
}

__PACKAGE__->meta->make_immutable;

1;

# vim: ts=2 sw=2 expandtab

__END__

=pod

=head1 NAME

DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated - (DEPRECATED) Use this if you are stuck in the past

=head1 DESCRIPTION

All this module does is override a few parts of
L<DBIx::Class::DeployMethd::SQL::Translator> so that the files generated with
L<DBIx::Class::Schema::Versioned> will work with this out of the box.

=head1 DEPRECATED

I begrudgingly made this module (and other related modules) to keep porting
from L<DBIx::Class::Schema::Versioned> relatively simple.  I will make changes
to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
but I will not add any new features to it.

Once I hit major version 1 usage of this module will emit a warning.
On version 2 it will be removed entirely.

=head1 THIS SUCKS

Yeah, this old Deprecated thing is a drag.  It can't do downgrades, it can only
use a single .sql file for migrations, it has no .pl support.  You should
totally switch!  Here's how:

 my $init_part = ref $schema;
 $init_part =~ s/::/-/g;
 opendir my $dh, 'sql';
 for (readdir $dh) {
   if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) {
    if (defined $3) {
      cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]);
    } else {
      cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1);
    }
  }
 }

=head1 OVERRIDDEN METHODS

=over

=item *

L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_consume_filenames>

=item *

L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_produce_filename>

=item *

L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_produce_filename>

=item *

L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_consume_filenames>

=back

=head1 SEE ALSO

This class is an implementation of
L<DBIx::Class::DeploymentHandler::HandlesDeploy>.  Pretty much all the
documentation is there.

=head1 AUTHOR

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut