Commit | Line | Data |
fe3b6dff |
1 | package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated; |
01342998 |
2 | use Moose; |
0df68524 |
3 | use Log::Contextual::WarnLogger; |
4 | use 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 |
11 | use Method::Signatures::Simple; |
12 | |
13 | has schema => ( |
14 | isa => 'DBIx::Class::Schema', |
15 | is => 'ro', |
16 | required => 1, |
17 | ); |
18 | |
19 | has 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 | |
26 | with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
27 | |
fe3b6dff |
28 | use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult; |
01342998 |
29 | sub _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 | |
37 | sub 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 |
44 | sub 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 | |
52 | 1; |
53 | |
e52174e3 |
54 | # vim: ts=2 sw=2 expandtab |
55 | |
01342998 |
56 | __END__ |
57 | |
bcc72297 |
58 | =head1 DEPRECATED |
59 | |
60 | I begrudgingly made this module (and other related modules) to keep porting |
61 | from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes |
62 | to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc, |
63 | but I will not add any new features to it. |
64 | |
65 | Once I hit major version 1 usage of this module will emit a warning. |
66 | On version 2 it will be removed entirely. |
67 | |
3885a58b |
68 | =head1 THIS SUCKS |
69 | |
70 | Here's how to convert from that crufty old Deprecated VersionStorage to a shiny |
71 | new 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 | |