line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1209242
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
3
|
|
|
|
|
|
|
package DBIx::Class::DeploymentHandler::VersionStorage::WithSchema; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Version storage for DeploymentHandler that includes the schema |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
6091
|
use DBIx::Class::DeploymentHandler::LogImporter ':log'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
1846
|
use DBIx::Class::DeploymentHandler::VersionStorage::WithSchema::VersionResult; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
339
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has schema => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has version_rs => ( |
18
|
|
|
|
|
|
|
isa => 'DBIx::Class::ResultSet', |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
builder => '_build_version_rs', |
21
|
|
|
|
|
|
|
handles => [qw/version_storage_is_installed/], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _build_version_rs { |
27
|
2
|
|
|
2
|
|
105
|
$_[0]->schema->register_class( |
28
|
|
|
|
|
|
|
__VERSION => |
29
|
|
|
|
|
|
|
'DBIx::Class::DeploymentHandler::VersionStorage::WithSchema::VersionResult' |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
1166
|
return $_[0]->schema->resultset('__VERSION') |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub database_version { |
36
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
37
|
0
|
|
|
|
|
0
|
my $schema = ref $self->schema; |
38
|
0
|
|
|
|
|
0
|
return $self->version_rs->search({ schema => $schema })->latest->get_column('version'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_database_version { |
42
|
1
|
|
|
1
|
0
|
7057
|
my $self = shift; |
43
|
1
|
|
|
|
|
4
|
my $version = $_[0]->{version}; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
40
|
my $schema = ref $self->schema; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
0
|
|
11
|
log_debug { "Adding version $version to schema $schema" }; |
|
0
|
|
|
|
|
0
|
|
48
|
1
|
|
|
|
|
112
|
$self->version_rs->create({ %{ $_[0] }, schema => $schema }); |
|
1
|
|
|
|
|
15
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub delete_database_version { |
52
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
my $version = $_[0]->{version}; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $schema = ref $self->schema; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
|
|
log_debug { "Deleting version $version from schema $schema" }; |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->version_rs->search({ version => $version, schema => $schema })->delete; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The standard DeploymentHandler storage only stores the version of the schema. |
68
|
|
|
|
|
|
|
This means you can't deploy multiple DH-handled DBIC schemata into the same |
69
|
|
|
|
|
|
|
database. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This module has an extra column to store the schema that it is deploying as well |
72
|
|
|
|
|
|
|
as the version. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
To use it, you'll have to create a new subclass of |
75
|
|
|
|
|
|
|
L<DBIx::Class::DeploymentHandler::Dad> that uses this module instead of the |
76
|
|
|
|
|
|
|
standard one, and instantiate that in your script instead. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This module implements L<DBIx::Class::DeploymentHandler::HandlesVersionStorage> |
81
|
|
|
|
|
|
|
and is similar to L<DBIx::Class::DeploymentHandler::VersionStorage::Standard>. |