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 => ( |
0905dc0e |
14 | is => 'ro', |
15 | required => 1, |
16 | ); |
17 | |
18 | has version_rs => ( |
19 | isa => 'DBIx::Class::ResultSet', |
20 | is => 'ro', |
53de57ed |
21 | builder => '_build_version_rs', |
0905dc0e |
22 | handles => [qw( database_version version_storage_is_installed )], |
23 | ); |
24 | |
25 | with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
26 | |
27 | sub _build_version_rs { |
6bbb6ce7 |
28 | $_[0]->schema->register_class( |
29 | __VERSION => |
30 | 'DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResult' |
31 | ); |
32 | $_[0]->schema->resultset('__VERSION') |
0905dc0e |
33 | } |
34 | |
0df68524 |
35 | sub add_database_version { |
36 | my $version = $_[1]->{version}; |
f4075791 |
37 | log_debug { "Adding database version $version" }; |
0df68524 |
38 | $_[0]->version_rs->create($_[1]) |
39 | } |
0905dc0e |
40 | |
f344dd91 |
41 | sub delete_database_version { |
0df68524 |
42 | my $version = $_[1]->{version}; |
f4075791 |
43 | log_debug { "Deleting database version $version" }; |
0df68524 |
44 | $_[0]->version_rs->search({ version => $version})->delete |
f344dd91 |
45 | } |
46 | |
c9149a81 |
47 | __PACKAGE__->meta->make_immutable; |
48 | |
0905dc0e |
49 | 1; |
50 | |
e52174e3 |
51 | # vim: ts=2 sw=2 expandtab |
52 | |
0905dc0e |
53 | __END__ |
54 | |
ec167a97 |
55 | =head1 SEE ALSO |
56 | |
57 | This class is an implementation of |
58 | L<DBIx::Class::DeploymentHandler::HandlesVersionStorage>. Pretty much all the |
59 | documentation is there. |