From f5b94098fb7d26bd2766941cf8f938cdf8b72aa0 Mon Sep 17 00:00:00 2001 From: Finn Date: Thu, 23 Nov 2017 13:20:26 +0000 Subject: [PATCH] Entity Assoiciations added to database --- lib/Pear/LocalLoop/Schema/Result/Entity.pm | 7 ++++ .../Schema/Result/EntityAssociation.pm | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 lib/Pear/LocalLoop/Schema/Result/EntityAssociation.pm diff --git a/lib/Pear/LocalLoop/Schema/Result/Entity.pm b/lib/Pear/LocalLoop/Schema/Result/Entity.pm index aa3df1b..7f1a7c9 100644 --- a/lib/Pear/LocalLoop/Schema/Result/Entity.pm +++ b/lib/Pear/LocalLoop/Schema/Result/Entity.pm @@ -44,6 +44,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "associations", + "Pear::LocalLoop::Schema::Result::EntityAssociation", + { "foreign.entity_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "sales", "Pear::LocalLoop::Schema::Result::Transaction", diff --git a/lib/Pear/LocalLoop/Schema/Result/EntityAssociation.pm b/lib/Pear/LocalLoop/Schema/Result/EntityAssociation.pm new file mode 100644 index 0000000..d547722 --- /dev/null +++ b/lib/Pear/LocalLoop/Schema/Result/EntityAssociation.pm @@ -0,0 +1,39 @@ +package Pear::LocalLoop::Schema::Result::EntityAssociation; + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->load_components(qw/ + InflateColumn::DateTime + TimeStamp +/); + +__PACKAGE__->table("entity_association"); + +__PACKAGE__->add_columns( + "id" => { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + }, + "entity_id" => { + data_type => 'integer', + is_nullable => 0, + is_foreign_key => 1, + }, + "lis" => { + data_type => 'boolean', + default => undef, + is_nullable => 1, + }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "entity", + "Pear::LocalLoop::Schema::Result::Entity", + "entity_id", +);