From a3a9f2baba52ed324ce1f69e9ddad2d983212e68 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Tue, 6 Aug 2013 01:50:49 +0200 Subject: [PATCH] Set correct relations between sipstats tables. --- lib/NGCP/Schema/Result/message_packets.pm | 14 ++++++++++++++ lib/NGCP/Schema/Result/messages.pm | 13 ++++++++++--- lib/NGCP/Schema/Result/packets.pm | 6 ++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/NGCP/Schema/Result/message_packets.pm b/lib/NGCP/Schema/Result/message_packets.pm index 1de50100..5dc8107a 100644 --- a/lib/NGCP/Schema/Result/message_packets.pm +++ b/lib/NGCP/Schema/Result/message_packets.pm @@ -25,6 +25,20 @@ __PACKAGE__->add_columns( { data_type => "bigint", extra => { unsigned => 1 }, is_nullable => 0 }, ); +__PACKAGE__->belongs_to( + "packet", + "NGCP::Schema::Result::packets", + { id => "packet" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +__PACKAGE__->belongs_to( + "message", + "NGCP::Schema::Result::messages", + { id => "message" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); __PACKAGE__->set_primary_key("message", "packet"); sub TO_JSON { diff --git a/lib/NGCP/Schema/Result/messages.pm b/lib/NGCP/Schema/Result/messages.pm index afe5c4a8..497a817a 100644 --- a/lib/NGCP/Schema/Result/messages.pm +++ b/lib/NGCP/Schema/Result/messages.pm @@ -12,7 +12,10 @@ our $VERSION = '2.003'; extends 'DBIx::Class::Core'; -__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); +__PACKAGE__->load_components( + "InflateColumn::DateTime", + "Helper::Row::ToJSON", +); __PACKAGE__->table("sipstats.messages"); @@ -71,6 +74,12 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 0, size => 255 }, ); +__PACKAGE__->has_many( + "message_packets", + "NGCP::Schema::Result::message_packets", + { "foreign.message" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); __PACKAGE__->set_primary_key("id"); sub TO_JSON { @@ -210,7 +219,5 @@ NGCP::Schema::Result::messages # Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-06-27 12:52:12 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bYbdYKBz9w7LgX1fXS2wzQ - -# You can replace this text with custom code or comments, and it will be preserved on regeneration __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/NGCP/Schema/Result/packets.pm b/lib/NGCP/Schema/Result/packets.pm index 0dd0e53d..05aa4feb 100644 --- a/lib/NGCP/Schema/Result/packets.pm +++ b/lib/NGCP/Schema/Result/packets.pm @@ -40,6 +40,12 @@ __PACKAGE__->add_columns( { data_type => "blob", is_nullable => 0 }, ); +__PACKAGE__->has_many( + "message_packets", + "NGCP::Schema::Result::message_packets", + { "foreign.packet" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); __PACKAGE__->set_primary_key("id"); sub TO_JSON {