File Coverage

blib/lib/Interchange6/Schema.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1 1     1   1053 use utf8;
  1         8  
  1         4  
2              
3             package Interchange6::Schema;
4              
5             =encoding utf8
6              
7             =head1 NAME
8              
9             Interchange6::Schema - Database Schema for Interchange 6
10              
11             =head1 VERSION
12              
13             0.082
14              
15             =cut
16              
17             our $VERSION = '0.082';
18              
19             =head1 DESCRIPTION
20              
21             Database schema classes for Interchange6 Open Source eCommerce
22             software.
23              
24             Components used:
25              
26             =over
27              
28             =item * L
29              
30             =item * L
31              
32             =back
33              
34             =cut
35              
36 1     1   47 use strict;
  1         1  
  1         25  
37 1     1   3 use warnings;
  1         1  
  1         28  
38              
39 1     1   4 use base 'DBIx::Class::Schema';
  1         1  
  1         446  
40              
41             __PACKAGE__->load_components( 'Helper::Schema::DateTime',
42             'Helper::Schema::QuoteNames', 'Schema::Config' );
43              
44             __PACKAGE__->load_namespaces(
45             default_resultset_class => 'ResultSet',
46             );
47              
48             =head1 MANUAL
49              
50             Please see the L for an overview of available documentation.
51              
52             =head1 METHODS
53              
54             =head2 deploy
55              
56             Overload L in order to add some core fixtures
57             via the following classes:
58              
59             =over
60              
61             =item * Interchange6::Schema::Populate::CountryLocale
62              
63             =item * Interchange6::Schema::Populate::MessageType
64              
65             =item * Interchange6::Schema::Populate::Role
66              
67             =item * Interchange6::Schema::Populate::StateLocale
68              
69             =item * Interchange6::Schema::Populate::Zone
70              
71             =back
72              
73             =cut
74              
75             {
76             use Interchange6::Schema::Populate::CountryLocale;
77             use Interchange6::Schema::Populate::MessageType;
78             use Interchange6::Schema::Populate::Role;
79             use Interchange6::Schema::Populate::StateLocale;
80             use Interchange6::Schema::Populate::Zone;
81              
82             sub deploy {
83             my $self = shift;
84             my $new = $self->next::method(@_);
85              
86             my $pop_country =
87             Interchange6::Schema::Populate::CountryLocale->new->records;
88             $self->resultset('Country')->populate($pop_country)
89             or die "Failed to populate Country";
90              
91             my $pop_messagetype =
92             Interchange6::Schema::Populate::MessageType->new->records;
93             $self->resultset('MessageType')->populate($pop_messagetype)
94             or die "Failed to populate MessageType";
95              
96             my $pop_role =
97             Interchange6::Schema::Populate::Role->new->records;
98             $self->resultset('Role')->populate($pop_role)
99             or die "Failed to populate Role";
100              
101             my $pop_state =
102             Interchange6::Schema::Populate::StateLocale->new->records;
103             my $states = $self->resultset('State')->populate($pop_state)
104             or die "Failed to populate State";
105              
106             my $min_states_id = $self->resultset('State')->search(
107             {},
108             {
109             select => [ { min => 'states_id' } ],
110             as => ['min_id'],
111             }
112             )->first->get_column('min_id');
113              
114             my $pop_zone =
115             Interchange6::Schema::Populate::Zone->new(
116             states_id_initial_value => $min_states_id )->records;
117             $self->resultset('Zone')->populate($pop_zone)
118             or die "Failed to populate Zone";
119             }
120             }
121              
122             1;
123              
124             __END__