Commit | Line | Data |
0905dc0e |
1 | package DBIx::Class::DeploymentHandler::VersionStorage::Standard; |
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 | }); |
9deabd1f |
8 | |
9 | # ABSTRACT: Version storage that does the normal stuff |
10 | |
53de57ed |
11 | use DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult; |
0905dc0e |
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', |
53de57ed |
22 | builder => '_build_version_rs', |
0905dc0e |
23 | handles => [qw( database_version version_storage_is_installed )], |
24 | ); |
25 | |
26 | with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
27 | |
28 | sub _build_version_rs { |
6bbb6ce7 |
29 | $_[0]->schema->register_class( |
30 | __VERSION => |
31 | 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult' |
32 | ); |
33 | $_[0]->schema->resultset('__VERSION') |
0905dc0e |
34 | } |
35 | |
0df68524 |
36 | sub add_database_version { |
37 | my $version = $_[1]->{version}; |
f4075791 |
38 | log_debug { "Adding database version $version" }; |
0df68524 |
39 | $_[0]->version_rs->create($_[1]) |
40 | } |
0905dc0e |
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 | |
c9149a81 |
48 | __PACKAGE__->meta->make_immutable; |
49 | |
0905dc0e |
50 | 1; |
51 | |
e52174e3 |
52 | # vim: ts=2 sw=2 expandtab |
53 | |
0905dc0e |
54 | __END__ |
55 | |
ec167a97 |
56 | =head1 SEE ALSO |
57 | |
58 | This class is an implementation of |
59 | L<DBIx::Class::DeploymentHandler::HandlesVersionStorage>. Pretty much all the |
60 | documentation is there. |