Commit | Line | Data |
fe3b6dff |
1 | package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated; |
01342998 |
2 | use Moose; |
8465e767 |
3 | use DBIx::Class::DeploymentHandler::Logger; |
c4f51462 |
4 | use 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 |
12 | has schema => ( |
01342998 |
13 | is => 'ro', |
14 | required => 1, |
15 | ); |
16 | |
17 | has 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 | |
24 | with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
25 | |
fe3b6dff |
26 | use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult; |
01342998 |
27 | sub _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 | |
35 | sub 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 |
42 | sub 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 | |
50 | 1; |
51 | |
e52174e3 |
52 | # vim: ts=2 sw=2 expandtab |
53 | |
01342998 |
54 | __END__ |
55 | |
bcc72297 |
56 | =head1 DEPRECATED |
57 | |
58 | I begrudgingly made this module (and other related modules) to keep porting |
59 | from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes |
60 | to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc, |
61 | but I will not add any new features to it. |
62 | |
63 | Once I hit major version 1 usage of this module will emit a warning. |
64 | On version 2 it will be removed entirely. |
65 | |
3885a58b |
66 | =head1 THIS SUCKS |
67 | |
68 | Here's how to convert from that crufty old Deprecated VersionStorage to a shiny |
69 | new 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 | |
88 | This class is an implementation of |
89 | L<DBIx::Class::DeploymentHandler::HandlesVersionStorage>. Pretty much all the |
90 | documentation is there. |