Improve docs by linking from implementations to their roles
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / VersionStorage / Deprecated.pm
CommitLineData
fe3b6dff 1package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated;
01342998 2use Moose;
8465e767 3use DBIx::Class::DeploymentHandler::Logger;
c4f51462 4use Log::Contextual ':log', -package_logger =>
8465e767 5 DBIx::Class::DeploymentHandler::Logger->new({
6 env_prefix => 'DBICDH'
7 });
0df68524 8
9deabd1f 9
10# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past
11
01342998 12has schema => (
13 isa => 'DBIx::Class::Schema',
14 is => 'ro',
15 required => 1,
16);
17
18has version_rs => (
19 isa => 'DBIx::Class::ResultSet',
20 is => 'ro',
fe3b6dff 21 builder => '_build_version_rs',
01342998 22 handles => [qw( database_version version_storage_is_installed )],
23);
24
25with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
26
fe3b6dff 27use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult;
01342998 28sub _build_version_rs {
29 $_[0]->schema->register_class(
30 dbix_class_schema_versions =>
31 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult'
32 );
33 $_[0]->schema->resultset('dbix_class_schema_versions')
34}
35
36sub add_database_version {
37 # deprecated doesn't support ddl or upgrade_ddl
0df68524 38 my $version = $_[1]->{version};
f4075791 39 log_debug { "Adding database version $version" };
0df68524 40 $_[0]->version_rs->create({ version => $version })
01342998 41}
42
f344dd91 43sub delete_database_version {
0df68524 44 my $version = $_[1]->{version};
f4075791 45 log_debug { "Deleting database version $version" };
0df68524 46 $_[0]->version_rs->search({ version => $version})->delete
f344dd91 47}
48
01342998 49__PACKAGE__->meta->make_immutable;
50
511;
52
e52174e3 53# vim: ts=2 sw=2 expandtab
54
01342998 55__END__
56
bcc72297 57=head1 DEPRECATED
58
59I begrudgingly made this module (and other related modules) to keep porting
60from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes
61to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc,
62but I will not add any new features to it.
63
64Once I hit major version 1 usage of this module will emit a warning.
65On version 2 it will be removed entirely.
66
3885a58b 67=head1 THIS SUCKS
68
69Here's how to convert from that crufty old Deprecated VersionStorage to a shiny
70new Standard VersionStorage:
71
72 my $s = My::Schema->connect(...);
73 my $dh = DeploymentHandler({
74 schema => $s,
75 });
76
77 $dh->prepare_version_storage_install;
78 $dh->install_version_storage;
79
80 my @versions = $s->{vschema}->resultset('Table')->search(undef, {
81 order_by => 'installed',
82 })->get_column('version')->all;
83
84 $dh->version_storage->add_database_vesion({ version => $_ })
85 for @versions;
86
ec167a97 87=head1 SEE ALSO
88
89This class is an implementation of
90L<DBIx::Class::DeploymentHandler::HandlesVersionStorage>. Pretty much all the
91documentation is there.