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