Refactored customer table and fixed all tests form that
This commit is contained in:
parent
d0cbb215d8
commit
f69b06bda2
13 changed files with 67 additions and 232 deletions
|
@ -1,107 +1,29 @@
|
|||
use utf8;
|
||||
package Pear::LocalLoop::Schema::Result::AgeRange;
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader
|
||||
# DO NOT MODIFY THE FIRST PART OF THIS FILE
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pear::LocalLoop::Schema::Result::AgeRange
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
=head1 COMPONENTS LOADED
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L<DBIx::Class::InflateColumn::DateTime>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->load_components("InflateColumn::DateTime");
|
||||
|
||||
=head1 TABLE: C<AgeRanges>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->table("AgeRanges");
|
||||
|
||||
=head1 ACCESSORS
|
||||
|
||||
=head2 agerangeid
|
||||
|
||||
data_type: 'integer'
|
||||
is_auto_increment: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 agerangestring
|
||||
|
||||
data_type: 'text'
|
||||
is_nullable: 0
|
||||
|
||||
=cut
|
||||
__PACKAGE__->table("age_ranges");
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"agerangeid",
|
||||
"id",
|
||||
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
|
||||
"agerangestring",
|
||||
"string",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
__PACKAGE__->set_primary_key("id");
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</agerangeid>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->set_primary_key("agerangeid");
|
||||
|
||||
=head1 UNIQUE CONSTRAINTS
|
||||
|
||||
=head2 C<agerangestring_unique>
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</agerangestring>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_unique_constraint("agerangestring_unique", ["agerangestring"]);
|
||||
|
||||
=head1 RELATIONS
|
||||
|
||||
=head2 customers
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Pear::LocalLoop::Schema::Result::Customer>
|
||||
|
||||
=cut
|
||||
__PACKAGE__->add_unique_constraint(["string"]);
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"customers",
|
||||
"Pear::LocalLoop::Schema::Result::Customer",
|
||||
{ "foreign.agerange_fk" => "self.agerangeid" },
|
||||
{ "foreign.age_range_id" => "self.id" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-02-24 17:32:21
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4zGNm0RlwptF9hlj9oErVA
|
||||
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
1;
|
||||
|
|
|
@ -1,137 +1,52 @@
|
|||
use utf8;
|
||||
package Pear::LocalLoop::Schema::Result::Customer;
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader
|
||||
# DO NOT MODIFY THE FIRST PART OF THIS FILE
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pear::LocalLoop::Schema::Result::Customer
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
=head1 COMPONENTS LOADED
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L<DBIx::Class::InflateColumn::DateTime>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->load_components("InflateColumn::DateTime");
|
||||
|
||||
=head1 TABLE: C<Customers>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->table("Customers");
|
||||
|
||||
=head1 ACCESSORS
|
||||
|
||||
=head2 customerid
|
||||
|
||||
data_type: 'integer'
|
||||
is_auto_increment: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 username
|
||||
|
||||
data_type: 'text'
|
||||
is_nullable: 0
|
||||
|
||||
=head2 agerange_fk
|
||||
|
||||
data_type: 'integer'
|
||||
is_foreign_key: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 postcode
|
||||
|
||||
data_type: 'text'
|
||||
is_nullable: 0
|
||||
|
||||
=cut
|
||||
__PACKAGE__->table("customers");
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"customerid",
|
||||
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
|
||||
"username",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"agerange_fk",
|
||||
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
|
||||
"postcode",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"id" => {
|
||||
data_type => "integer",
|
||||
is_auto_increment => 1,
|
||||
is_nullable => 0,
|
||||
},
|
||||
"username" => {
|
||||
data_type => "varchar",
|
||||
size => 255,
|
||||
is_nullable => 0,
|
||||
},
|
||||
"age_range_id" => {
|
||||
data_type => "integer",
|
||||
is_foreign_key => 1,
|
||||
is_nullable => 0,
|
||||
},
|
||||
"postcode" => {
|
||||
data_type => "varchar",
|
||||
size => 16,
|
||||
is_nullable => 0,
|
||||
},
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
__PACKAGE__->set_primary_key("id");
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</customerid>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->set_primary_key("customerid");
|
||||
|
||||
=head1 UNIQUE CONSTRAINTS
|
||||
|
||||
=head2 C<username_unique>
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</username>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_unique_constraint("username_unique", ["username"]);
|
||||
|
||||
=head1 RELATIONS
|
||||
|
||||
=head2 agerange_fk
|
||||
|
||||
Type: belongs_to
|
||||
|
||||
Related object: L<Pear::LocalLoop::Schema::Result::AgeRange>
|
||||
|
||||
=cut
|
||||
__PACKAGE__->add_unique_constraint(["username"]);
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"agerange_fk",
|
||||
"age_range",
|
||||
"Pear::LocalLoop::Schema::Result::AgeRange",
|
||||
{ agerangeid => "agerange_fk" },
|
||||
{ id => "age_range_id" },
|
||||
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
||||
);
|
||||
|
||||
=head2 user
|
||||
|
||||
Type: might_have
|
||||
|
||||
Related object: L<Pear::LocalLoop::Schema::Result::User>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->might_have(
|
||||
"user",
|
||||
"Pear::LocalLoop::Schema::Result::User",
|
||||
{ "foreign.customer_id" => "self.customerid" },
|
||||
{ "foreign.customer_id" => "self.id" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-02-24 17:32:21
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ocoCGZYvw9O9wxzr14okiQ
|
||||
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
1;
|
||||
|
|
|
@ -70,7 +70,7 @@ __PACKAGE__->might_have(
|
|||
__PACKAGE__->belongs_to(
|
||||
"customer",
|
||||
"Pear::LocalLoop::Schema::Result::Customer",
|
||||
{ customerid => "customer_id" },
|
||||
{ id => "customer_id" },
|
||||
{
|
||||
is_deferrable => 0,
|
||||
join_type => "LEFT",
|
||||
|
|
Reference in a new issue