| 1 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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.081 | ||||||||||
| 14 | |||||||||||
| 15 | =cut | ||||||||||
| 16 | |||||||||||
| 17 | 2 | our $VERSION = '0.081'; | |||||||||
| 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<DBIx::Class::Helper::Schema::DateTime> | ||||||||||
| 29 | |||||||||||
| 30 | =item * L<DBIx::Class::Helper::Schema::QuoteNames> | ||||||||||
| 31 | |||||||||||
| 32 | =back | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | use base 'DBIx::Class::Schema'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | 2 | __PACKAGE__->load_components( 'Helper::Schema::DateTime', | |||||||||
| 42 | 'Helper::Schema::QuoteNames', 'Schema::Config' ); | ||||||||||
| 43 | |||||||||||
| 44 | 2 | __PACKAGE__->load_namespaces( | |||||||||
| 45 | default_resultset_class => 'ResultSet', | ||||||||||
| 46 | ); | ||||||||||
| 47 | |||||||||||
| 48 | =head1 MANUAL | ||||||||||
| 49 | |||||||||||
| 50 | Please see the L<Interchange6 Schema Manual|Interchange6::Schema::Manual> for an overview of available documentation. | ||||||||||
| 51 | |||||||||||
| 52 | =head1 METHODS | ||||||||||
| 53 | |||||||||||
| 54 | =head2 deploy | ||||||||||
| 55 | |||||||||||
| 56 | Overload L<DBIx::Class::Schema/deploy> 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 | 2 | ▶ | use Interchange6::Schema::Populate::CountryLocale; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 77 | 2 | ▶ | use Interchange6::Schema::Populate::MessageType; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 78 | 2 | ▶ | use Interchange6::Schema::Populate::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 79 | 2 | ▶ | use Interchange6::Schema::Populate::StateLocale; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 80 | 2 | ▶ | use Interchange6::Schema::Populate::Zone; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 81 | |||||||||||
| 82 | sub deploy { | ||||||||||
| 83 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
deploy: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||
| 84 | 1 | my $new = $self->next::method(@_); | |||||||||
| 85 | |||||||||||
| 86 | 1 | my $pop_country = | |||||||||
| 87 | Interchange6::Schema::Populate::CountryLocale->new->records; | ||||||||||
| 88 | 1 | ▶ | $self->resultset('Country')->populate($pop_country) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | or die "Failed to populate Country"; | ||||||||||
| 90 | |||||||||||
| 91 | 1 | my $pop_messagetype = | |||||||||
| 92 | Interchange6::Schema::Populate::MessageType->new->records; | ||||||||||
| 93 | 1 | ▶ | $self->resultset('MessageType')->populate($pop_messagetype) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | or die "Failed to populate MessageType"; | ||||||||||
| 95 | |||||||||||
| 96 | 1 | my $pop_role = | |||||||||
| 97 | Interchange6::Schema::Populate::Role->new->records; | ||||||||||
| 98 | 1 | ▶ | $self->resultset('Role')->populate($pop_role) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | or die "Failed to populate Role"; | ||||||||||
| 100 | |||||||||||
| 101 | 1 | my $pop_state = | |||||||||
| 102 | Interchange6::Schema::Populate::StateLocale->new->records; | ||||||||||
| 103 | 1 | ▶ | my $states = $self->resultset('State')->populate($pop_state) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | or die "Failed to populate State"; | ||||||||||
| 105 | |||||||||||
| 106 | 1 | 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 | 1 | my $pop_zone = | |||||||||
| 115 | Interchange6::Schema::Populate::Zone->new( | ||||||||||
| 116 | states_id_initial_value => $min_states_id )->records; | ||||||||||
| 117 | 1 | ▶ | $self->resultset('Zone')->populate($pop_zone) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | or die "Failed to populate Zone"; | ||||||||||
| 119 | } | ||||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 2 | 1; | |||||||||
| 123 | |||||||||||
| 124 | __END__ | ||||||||||
| 125 | |||||||||||
| 126 | =head1 CREATE SQL FILES FOR DATABASE SCHEMA | ||||||||||
| 127 | |||||||||||
| 128 | This command creates SQL files for our database schema | ||||||||||
| 129 | in the F<sql/> directory: | ||||||||||
| 130 | |||||||||||
| 131 | interchange6-create-database | ||||||||||
| 132 | |||||||||||
| 133 | =head1 POLICY FOR RELATIONSHIP ACCESSORS | ||||||||||
| 134 | |||||||||||
| 135 | =over 4 | ||||||||||
| 136 | |||||||||||
| 137 | =item All lower case | ||||||||||
| 138 | |||||||||||
| 139 | =item Singular names for belongs_to and has_one relationships | ||||||||||
| 140 | |||||||||||
| 141 | =item Pluralised names for many_to_many and has_many relationships | ||||||||||
| 142 | |||||||||||
| 143 | =item Use underscores for things like C<shipment_destinations>. | ||||||||||
| 144 | |||||||||||
| 145 | =back | ||||||||||
| 146 | |||||||||||
| 147 | =head1 AUTHORS | ||||||||||
| 148 | |||||||||||
| 149 | Stefan Hornburg (Racke), C<racke@linuxia.de> | ||||||||||
| 150 | |||||||||||
| 151 | Peter Mottram, C<peter@sysnix.com> | ||||||||||
| 152 | |||||||||||
| 153 | Jeff Boes, C<jeff@endpoint.com> | ||||||||||
| 154 | |||||||||||
| 155 | Sam Batschelet C<sbatschelet@mac.com> | ||||||||||
| 156 | |||||||||||
| 157 | =head1 CONTRIBUTORS | ||||||||||
| 158 | |||||||||||
| 159 | Kaare Rasmussen | ||||||||||
| 160 | Šimun Kodžoman | ||||||||||
| 161 | Grega Pompe | ||||||||||
| 162 | |||||||||||
| 163 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 164 | |||||||||||
| 165 | Copyright 2013-2014 Stefan Hornburg (Racke), Jeff Boes. | ||||||||||
| 166 | |||||||||||
| 167 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 168 | under the terms of either: the GNU General Public License as published | ||||||||||
| 169 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 170 | |||||||||||
| 171 | See http://dev.perl.org/licenses/ for more information. | ||||||||||