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 | use Method::Signatures::Simple; |
13 | |
14 | has schema => ( |
15 | isa => 'DBIx::Class::Schema', |
16 | is => 'ro', |
17 | required => 1, |
18 | ); |
19 | |
20 | has 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 | |
27 | with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
28 | |
fe3b6dff |
29 | use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult; |
01342998 |
30 | sub _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 | |
38 | sub add_database_version { |
39 | # deprecated doesn't support ddl or upgrade_ddl |
0df68524 |
40 | my $version = $_[1]->{version}; |
f4075791 |
41 | log_debug { "Adding database version $version" }; |
0df68524 |
42 | $_[0]->version_rs->create({ version => $version }) |
01342998 |
43 | } |
44 | |
f344dd91 |
45 | sub delete_database_version { |
0df68524 |
46 | my $version = $_[1]->{version}; |
f4075791 |
47 | log_debug { "Deleting database version $version" }; |
0df68524 |
48 | $_[0]->version_rs->search({ version => $version})->delete |
f344dd91 |
49 | } |
50 | |
01342998 |
51 | __PACKAGE__->meta->make_immutable; |
52 | |
53 | 1; |
54 | |
e52174e3 |
55 | # vim: ts=2 sw=2 expandtab |
56 | |
01342998 |
57 | __END__ |
58 | |
bcc72297 |
59 | =head1 DEPRECATED |
60 | |
61 | I begrudgingly made this module (and other related modules) to keep porting |
62 | from L<DBIx::Class::Schema::Versioned> relatively simple. I will make changes |
63 | to ensure that it works with output from L<DBIx::Class::Schema::Versioned> etc, |
64 | but I will not add any new features to it. |
65 | |
66 | Once I hit major version 1 usage of this module will emit a warning. |
67 | On version 2 it will be removed entirely. |
68 | |
3885a58b |
69 | =head1 THIS SUCKS |
70 | |
71 | Here's how to convert from that crufty old Deprecated VersionStorage to a shiny |
72 | new 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 | |