diff --git a/MANIFEST b/MANIFEST index 8e5ceb6..20d22a5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -20,6 +20,9 @@ lib/Interchange6/Schema/Result/Cart.pm lib/Interchange6/Schema/Result/CartProduct.pm lib/Interchange6/Schema/Result/Country.pm lib/Interchange6/Schema/Result/Inventory.pm +lib/Interchange6/Schema/Result/InventoryLog.pm +lib/Interchange6/Schema/Result/Location.pm +lib/Interchange6/Schema/Result/LocationType.pm lib/Interchange6/Schema/Result/Media.pm lib/Interchange6/Schema/Result/MediaDisplay.pm lib/Interchange6/Schema/Result/MediaProduct.pm @@ -43,6 +46,7 @@ lib/Interchange6/Schema/Result/Product.pm lib/Interchange6/Schema/Result/ProductAttribute.pm lib/Interchange6/Schema/Result/ProductAttributeValue.pm lib/Interchange6/Schema/Result/ProductReview.pm +lib/Interchange6/Schema/Result/ProductSupplier.pm lib/Interchange6/Schema/Result/Role.pm lib/Interchange6/Schema/Result/Session.pm lib/Interchange6/Schema/Result/Setting.pm @@ -52,6 +56,7 @@ lib/Interchange6/Schema/Result/ShipmentDestination.pm lib/Interchange6/Schema/Result/ShipmentRate.pm lib/Interchange6/Schema/Result/ShipmentMethod.pm lib/Interchange6/Schema/Result/State.pm +lib/Interchange6/Schema/Result/Supplier.pm lib/Interchange6/Schema/Result/Tax.pm lib/Interchange6/Schema/Result/User.pm lib/Interchange6/Schema/Result/UserAttribute.pm @@ -94,3 +99,4 @@ t/lib/Test/Tax.pm t/lib/Test/User.pm t/lib/Test/Variant.pm t/lib/Test/Zone.pm + diff --git a/lib/Interchange6/Schema/Result/Address.pm b/lib/Interchange6/Schema/Result/Address.pm index 87f0404..b6976b0 100644 --- a/lib/Interchange6/Schema/Result/Address.pm +++ b/lib/Interchange6/Schema/Result/Address.pm @@ -339,4 +339,31 @@ Composing rels: L -> orderline many_to_many orderlines => "orderlines_shipping", "orderline"; +=head2 locations + +Type: has_many + +Related object: L + +=cut + +has_many + locations => "Interchange6::Schema::Result::Location", + { "foreign.addresses_id" => "self.addresses_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + +=head2 suppliers + +Type: has_many + +Related object: L + +=cut + +has_many + suppliers => "Interchange6::Schema::Result::Supplier", + { "foreign.addresses_id" => "self.addresses_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + + 1; diff --git a/lib/Interchange6/Schema/Result/InventoryLog.pm b/lib/Interchange6/Schema/Result/InventoryLog.pm new file mode 100644 index 0000000..9c95e71 --- /dev/null +++ b/lib/Interchange6/Schema/Result/InventoryLog.pm @@ -0,0 +1,132 @@ +use utf8; +package Interchange6::Schema::Result::InventoryLog; + +=head1 NAME + +Interchange6::Schema::Result::InventoryLog + +=cut + +use Interchange6::Schema::Candy -components => + [qw(InflateColumn::DateTime TimeStamp)]; + +=head1 ACCESSORS + +=head2 inventory_logs_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + primary key + +=cut + +primary_column inventory_logs_id => { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, +}; + +=head2 sku + + data_type: 'varchar' + is_foreign_key_constraint: 1 + is_nullable: 0 + size: 64 + +=cut + +column sku => { + data_type => "varchar", + is_foreign_key_constraint => 1, + is_nullable => 0, + size => 64, +}; + +=head2 datetime + + data_type: 'datetime' + set_on_create: 1 + is_nullable: 0 + +=cut + +column datetime => { + data_type => "datetime", + set_on_create => 1, + is_nullable => 0 +}; + +=head2 quantity + + data_type: 'numeric' + size: [9,2] + is_nullable: 0 + default_value: 0 + +=cut + +column quantity => { + data_type => 'numeric', + size => [9,2], + is_nullable => 0, + default_value => 0, +}; + +=head2 locations_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +column locations_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head2 suppliers_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +column suppliers_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head1 RELATIONS + +=head2 locations + +Type: has_many + +Related object: L + +=cut + +belongs_to + locations => "Interchange6::Schema::Result::Location", + { "foreign.locations_id" => "self.locations_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +=head2 product_suppliers + +Type: has_many + +Related object: L + +=cut + +belongs_to + product_suppliers => "Interchange6::Schema::Result::ProductSupplier", + { "foreign.suppliers_id" => "self.suppliers_id", "foreign.sku" => "self.sku"}, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +1; \ No newline at end of file diff --git a/lib/Interchange6/Schema/Result/Location.pm b/lib/Interchange6/Schema/Result/Location.pm new file mode 100644 index 0000000..4f292fb --- /dev/null +++ b/lib/Interchange6/Schema/Result/Location.pm @@ -0,0 +1,156 @@ +use utf8; +package Interchange6::Schema::Result::Location; + +=head1 NAME + +Interchange6::Schema::Result::Location + +=cut + +use Interchange6::Schema::Candy -components => + [qw(InflateColumn::DateTime TimeStamp)]; + +=head1 ACCESSORS + +=head2 locations_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + primary key + +=cut + +primary_column locations_id => { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, +}; + +=head2 name + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 255 + +=cut + +column name => { + data_type => "varchar", + default_value => "", + is_nullable => 0, + size => 255, +}; + +=head2 parents_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 1 + +=cut + +column parents_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 1, +}; + + +=head2 addresses_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +column addresses_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head2 location_types_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +column location_types_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head1 RELATIONS + +=head2 addresses + +Type: belongs_to + +Related object: L + +=cut + +belongs_to + addresses => "Interchange6::Schema::Result::Address", + { "foreign.addresses_id" => "self.addresses_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +=head2 children + +Type: has_many + +Related object: L + +=cut + +has_many + children => "Interchange6::Schema::Result::Location", + { "foreign.parents_id" => "self.locations_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + +=head2 parents + +Type: belongs_to + +Related object: L + +=cut + +belongs_to + parents => "Interchange6::Schema::Result::Location", + { "foreign.locations_id" => "self.parents_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +=head2 location_types + +Type: belongs_to + +Related object: L + +=cut + +belongs_to + location_types => "Interchange6::Schema::Result::LocationType", + { "foreign.location_types_id" => "self.location_types_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +=head2 inventory_logs + +Type: has_many + +Related object: L + +=cut + +has_many + inventory_logs => "Interchange6::Schema::Result::InventoryLog", + { "foreign.locations_id" => "self.locations_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + +1; \ No newline at end of file diff --git a/lib/Interchange6/Schema/Result/LocationType.pm b/lib/Interchange6/Schema/Result/LocationType.pm new file mode 100644 index 0000000..4e8ae6c --- /dev/null +++ b/lib/Interchange6/Schema/Result/LocationType.pm @@ -0,0 +1,61 @@ +use utf8; +package Interchange6::Schema::Result::LocationType; + +=head1 NAME + +Interchange6::Schema::Result::LocationType + +=cut + +use Interchange6::Schema::Candy -components => + [qw(InflateColumn::DateTime TimeStamp)]; + +=head1 ACCESSORS + +=head2 location_types_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + primary key + +=cut + +primary_column location_types_id => { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, +}; + +=head2 name + + data_type: 'varchar' + default_value: (empty string) + size: 45 + is_nullable: 0 + +=cut + +column name => { + data_type => "varchar", + default_value => "", + size => 45, + is_nullable => 0, +}; + +=head1 RELATIONS + +=head2 locations + +Type: has_many + +Related object: L + +=cut + +has_many + locations => "Interchange6::Schema::Result::Location", + { "foreign.location_types_id" => "self.location_types_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + +1; \ No newline at end of file diff --git a/lib/Interchange6/Schema/Result/Product.pm b/lib/Interchange6/Schema/Result/Product.pm index c5fb6f5..ce212ef 100644 --- a/lib/Interchange6/Schema/Result/Product.pm +++ b/lib/Interchange6/Schema/Result/Product.pm @@ -384,7 +384,7 @@ This is considered a private method. Please see public L metho has_many _product_reviews => "Interchange6::Schema::Result::ProductReview", - "sku", { cascade_copy => 0 }; + "sku"; =head2 _reviews @@ -396,6 +396,33 @@ This is considered a private method. Accessor to related Message results. Please many_to_many _reviews => "_product_reviews", "message"; +=head2 product_suppliers + +Type: has_many + +Related object: L + +=cut + +has_many + product_suppliers => "Interchange6::Schema::Result::ProductSupplier", + { "foreign.sku" => "self.sku" }, + { cascade_copy => 0, cascade_delete => 0 }; + +=head2 inventory_logs + +Type: has_many + +Related object: L + +=cut + +has_many + inventory_logs => "Interchange6::Schema::Result::InventoryLog", + { "foreign.sku" => "self.sku" }, + { cascade_copy => 0, cascade_delete => 0 }; + + =head1 METHODS Attribute methods are provided by the L class. diff --git a/lib/Interchange6/Schema/Result/ProductSupplier.pm b/lib/Interchange6/Schema/Result/ProductSupplier.pm new file mode 100644 index 0000000..858e8c3 --- /dev/null +++ b/lib/Interchange6/Schema/Result/ProductSupplier.pm @@ -0,0 +1,88 @@ +use utf8; +package Interchange6::Schema::Result::ProductSupplier; + +=head1 NAME + +Interchange6::Schema::Result::ProductSupplier + +=cut + +use Interchange6::Schema::Candy -components => + [qw(InflateColumn::DateTime TimeStamp)]; + +=head1 ACCESSORS + +=head2 suppliers_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +primary_column suppliers_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head2 sku + + data_type: 'varchar' + is_foreign_key_constraint: 1 + size: 64 + is_nullable: 0 + +=cut + +primary_column sku => { + data_type => "varchar", + size => 64, + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head1 RELATIONS + +=head2 products + +Type: belongs_to + +Related object: L + +=cut + +belongs_to + products => "Interchange6::Schema::Result::Product", + { "foreign.sku" => "self.sku" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +=head2 inventory_logs + +Type: has_many + +Related object: L + +=cut + +has_many + inventory_logs => "Interchange6::Schema::Result::InventoryLog", + { "foreign.suppliers_id" => "self.suppliers_id", "foreign.sku" => "self.sku"}, + { cascade_copy => 0, cascade_delete => 0 }; + + +=head2 product_suppliers + +Type: has_many + +Related object: L + +=cut + +belongs_to + product_suppliers => "Interchange6::Schema::Result::Supplier", + { "foreign.suppliers_id" => "self.suppliers_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + + +1; \ No newline at end of file diff --git a/lib/Interchange6/Schema/Result/Supplier.pm b/lib/Interchange6/Schema/Result/Supplier.pm new file mode 100644 index 0000000..6ecf9fa --- /dev/null +++ b/lib/Interchange6/Schema/Result/Supplier.pm @@ -0,0 +1,136 @@ +use utf8; +package Interchange6::Schema::Result::Supplier; + +=head1 NAME + +Interchange6::Schema::Result::Supplier + +=cut + +use Interchange6::Schema::Candy -components => + [qw(InflateColumn::DateTime TimeStamp)]; + +=head1 ACCESSORS + +=head2 suppliers_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + primary key + +=cut + +primary_column suppliers_id => { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, +}; + +=head2 name + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 255 + +=cut + +column name => { + data_type => "varchar", + default_value => "", + is_nullable => 0, + size => 255, +}; + +=head2 addresses_id + + data_type: 'integer' + is_foreign_key_constraint: 1 + is_nullable: 0 + +=cut + +column addresses_id => { + data_type => "integer", + is_foreign_key_constraint => 1, + is_nullable => 0, +}; + +=head2 tax_id + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 45 + +=cut + +column tax_id => { + data_type => "varchar", + default_value => "", + is_nullable => 0, + size => 45, +}; + +=head2 phone + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 45 + +=cut + +column phone => { + data_type => "varchar", + default_value => "", + is_nullable => 0, + size => 45, +}; + +=head2 email + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 45 + +=cut + +column email => { + data_type => "varchar", + default_value => "", + is_nullable => 0, + size => 45, +}; + +=head1 RELATIONS + +=head2 product_suppliers + +Type: has_many + +Related object: L + +=cut + +has_many + product_suppliers => "Interchange6::Schema::Result::ProductSupplier", + { "foreign.suppliers_id" => "self.suppliers_id" }, + { cascade_copy => 0, cascade_delete => 0 }; + +=head2 addresses + +Type: belongs_to + +Related object: L + +=cut + +belongs_to + addresses => "Interchange6::Schema::Result::Address", + { "foreign.addresses_id" => "self.addresses_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; + +1; \ No newline at end of file diff --git a/t/schema_sanity.t b/t/schema_sanity.t index 4efbc4b..a83daff 100644 --- a/t/schema_sanity.t +++ b/t/schema_sanity.t @@ -156,7 +156,7 @@ test 'schema_sanity' => sub { && cmp_ok( $size, '>=', 1, "size >= 1 for $source_name $column" ); } - elsif ( $data_type eq 'numeric' ) { + elsif ( $data_type =~ /^(numeric|decimal)$/) { ok( defined $size, "size is defined for $source_name $column" ) && ok( ref($size) eq 'ARRAY', "and is an array" ) && cmp_ok( scalar @$size, '==', 2, "that has 2 elements" )