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