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