Commit | Line | Data |
3c1b5ee8 |
1 | package DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated; |
2 | use Moose; |
9deabd1f |
3 | |
4 | # ABSTRACT: (DEPRECATED) Use this if you are stuck in the past |
5 | |
3c1b5ee8 |
6 | use Method::Signatures::Simple; |
7 | |
42c2fec3 |
8 | use File::Spec::Functions; |
1f0d0633 |
9 | require SQL::Translator::Diff; |
42c2fec3 |
10 | |
3c1b5ee8 |
11 | extends 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator', |
12 | |
42c2fec3 |
13 | method _ddl_schema_consume_filenames($type, $version) { |
3885a58b |
14 | return [$self->_ddl_schema_produce_filename($type, $version)] |
42c2fec3 |
15 | } |
16 | |
17 | method _ddl_schema_produce_filename($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 | |
42c2fec3 |
28 | method _ddl_schema_up_produce_filename($type, $versions, $dir) { |
3c1b5ee8 |
29 | my $filename = ref $self->schema; |
30 | $filename =~ s/::/-/g; |
31 | |
42c2fec3 |
32 | $filename = catfile( |
91adde75 |
33 | $self->script_directory, "$filename-" . join( q(-), @{$versions} ) . "-$type.sql" |
3c1b5ee8 |
34 | ); |
35 | |
42c2fec3 |
36 | return $filename; |
3c1b5ee8 |
37 | } |
38 | |
42c2fec3 |
39 | method _ddl_schema_up_consume_filenames($type, $versions) { |
3885a58b |
40 | return [$self->_ddl_schema_up_produce_filename($type, $versions)] |
42c2fec3 |
41 | } |
42 | |
1f0d0633 |
43 | method _generate_final_diff($source_schema, $dest_schema, $db, $sqltargs) { |
44 | scalar SQL::Translator::Diff::schema_diff( |
45 | $source_schema, $db, |
46 | $dest_schema, $db, |
47 | $sqltargs |
48 | ) |
49 | } |
50 | |
51 | method _default_read_sql_file_as_string($file) { |
52 | do { local( @ARGV, $/ ) = $file; <> } # slurp |
53 | } |
54 | |
55 | method _generate_final_sql($sqlt) { scalar $sqlt->translate } |
56 | |
42c2fec3 |
57 | __PACKAGE__->meta->make_immutable; |
58 | |
3c1b5ee8 |
59 | 1; |
3885a58b |
60 | |
e52174e3 |
61 | # vim: ts=2 sw=2 expandtab |
62 | |
3885a58b |
63 | __END__ |
64 | |
bcc72297 |
65 | =head1 DESCRIPTION |
66 | |
67 | All this module does is override a few parts of |
68 | L<DBIx::Class::DeployMethd::SQL::Translator> so that the files generated with |
69 | L<DBIx::Class::Schema::Versioned> will work with this out of the box. |
70 | |
71 | =head1 DEPRECATED |
72 | |
73 | I begrudgingly made this module (and other related modules) to keep porting |
74 | from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes |
75 | to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc, |
76 | but I will not add any new features to it. |
77 | |
78 | Once I hit major version 1 usage of this module will emit a warning. |
79 | On version 2 it will be removed entirely. |
80 | |
3885a58b |
81 | =head1 THIS SUCKS |
82 | |
83 | Yeah, this old Deprecated thing is a drag. It can't do downgrades, it can only |
84 | use a single .sql file for migrations, it has no .pl support. You should |
85 | totally switch! Here's how: |
86 | |
87 | my $init_part = ref $schema; |
88 | $init_part =~ s/::/-/g; |
89 | opendir my $dh, 'sql'; |
90 | for (readdir $dh) { |
91 | if (/\Q$init_part\E-(.*)-(.*)(?:-(.*))?/) { |
92 | if (defined $3) { |
93 | cp $_, $dh->deploy_method->_ddl_schema_up_produce_filename($3, [$1, $2]); |
94 | } else { |
95 | cp $_, $dh->deploy_method->_ddl_schema_produce_filename($2, $1); |
96 | } |
97 | } |
98 | } |
99 | |
bcc72297 |
100 | =head1 OVERRIDDEN METHODS |
101 | |
102 | =over |
103 | |
104 | =item * |
105 | |
106 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_consume_filenames> |
107 | |
108 | =item * |
109 | |
110 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_produce_filename> |
111 | |
112 | =item * |
113 | |
114 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_produce_filename> |
115 | |
116 | =item * |
117 | |
118 | L<DBIx::Class::DeployMethod::SQL::Translator/_ddl_schema_up_consume_filenames> |
119 | |
120 | =back |
121 | |