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