Port to Moo
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Deprecated.pm
1 package DBIx::Class::DeploymentHandler::Deprecated;
2
3 # ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
4
5 use Moose;
6 use Moose::Util 'apply_all_roles';
7
8 extends 'DBIx::Class::DeploymentHandler::Dad';
9 use DBIx::Class::DeploymentHandler::WithApplicatorDumple2;
10 # a single with would be better, but we can't do that
11 # see: http://rt.cpan.org/Public/Bug/Display.html?id=46347
12 with WithApplicatorDumple2(
13     interface_role       => 'DBIx::Class::DeploymentHandler::HandlesDeploy',
14     class_name           => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated',
15     delegate_name        => 'deploy_method',
16     attributes_to_assume => ['schema'],
17     attributes_to_copy   => [qw( script_directory databases sql_translator_args )],
18   ),
19   WithApplicatorDumple2(
20     interface_role       => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
21     class_name           => 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated',
22     delegate_name        => 'version_storage',
23     attributes_to_assume => ['schema'],
24   );
25 with 'DBIx::Class::DeploymentHandler::WithReasonableDefaults';
26
27 sub BUILD {
28   my $self = shift;
29
30   if ($self->schema->can('ordered_versions') && $self->schema->ordered_versions) {
31     apply_all_roles(
32       $self,
33       WithApplicatorDumple2(
34         interface_role       => 'DBIx::Class::DeploymentHandler::HandlesVersioning',
35         class_name           => 'DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions',
36         delegate_name        => 'version_handler',
37         attributes_to_assume => [qw( database_version schema_version to_version )],
38       )
39     );
40   } else {
41     apply_all_roles(
42       $self,
43       WithApplicatorDumple2(
44         interface_role       => 'DBIx::Class::DeploymentHandler::HandlesVersioning',
45         class_name           => 'DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions',
46         delegate_name        => 'version_handler',
47         attributes_to_assume => [qw( database_version schema_version to_version )],
48       )
49     );
50   }
51   # the following is just a hack so that ->version_storage
52   # won't be lazy
53   $self->version_storage;
54 }
55
56 __PACKAGE__->meta->make_immutable;
57
58 1;
59
60 # vim: ts=2 sw=2 expandtab
61
62 __END__
63
64 =head1 DEPRECATED
65
66 I begrudgingly made this module (and other related modules) to make porting
67 from L<DBIx::Class::Schema::Versioned> relatively simple.  I will make changes
68 to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
69 but I will not add any new features to it.  It already lacks numerous features
70 that the full version provides in style:
71
72 =over
73
74 =item *
75
76 Downgrades
77
78 =item *
79
80 Multiple files for migrations
81
82 =item *
83
84 Perl files in migrations
85
86 =item *
87
88 Shared Perl/SQL for different databases
89
90 =back
91
92 And there's probably more.
93
94 At version 1.000000 usage of this module will emit a warning.  At version
95 2.000000 it will be removed entirely.
96
97 To migrate to the New Hotness take a look at:
98 L<DBIx::Class::DeploymentHandler::VersionStorage::Deprecated/THIS SUCKS> and
99 L<DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated/THIS SUCKS>.
100
101 =head1 SYNOPSIS
102
103 Look at L<DBIx::Class::DeploymentHandler/SYNPOSIS>.  I won't repeat
104 it here to emphasize, yet again, that this should not be used unless you really
105 want to live in the past.
106
107 =head1 WHERE IS ALL THE DOC?!
108
109 C<DBIx::Class::DeploymentHandler::Deprecated> extends
110 L<DBIx::Class::DeploymentHandler::Dad>, so that's probably the first place to
111 look when you are trying to figure out how everything works.
112
113 Next would be to look at all the pieces that fill in the blanks that
114 L<DBIx::Class::DeploymentHandler::Dad> expects to be filled.  They would be
115 L<DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated>,
116 L<DBIx::Class::DeploymentHandler::VersionStorage::Deprecated>, and
117 L<DBIx::Class::DeploymentHandler::WithReasonableDefaults>.  Also, this class
118 is special in that it applies either
119 L<DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions> or
120 L<DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions> depending on
121 your schema.