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