From e95561ac824a4d85b9234cabb2c9c0439792ed54 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Wed, 30 Nov 2016 15:14:31 +0200 Subject: [PATCH] TT#5954 Add announcement relation to cf destination Change-Id: Id4c5073e2dc2d6712cebdb235929fb12a71a4a43 --- lib/NGCP/Schema/Result/voip_cf_destinations.pm | 14 ++++++++++++++ lib/NGCP/Schema/Result/voip_sound_handles.pm | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/lib/NGCP/Schema/Result/voip_cf_destinations.pm b/lib/NGCP/Schema/Result/voip_cf_destinations.pm index 58dd73ff..a1025369 100644 --- a/lib/NGCP/Schema/Result/voip_cf_destinations.pm +++ b/lib/NGCP/Schema/Result/voip_cf_destinations.pm @@ -34,6 +34,13 @@ __PACKAGE__->add_columns( extra => { unsigned => 1 }, is_nullable => 0, }, + "announcement_id", + { + data_type => "integer", + extra => { unsigned => 0 }, + is_foreign_key => 1, + is_nullable => 1, + }, ); __PACKAGE__->set_primary_key("id"); @@ -45,6 +52,13 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->belongs_to( + "voip_sound_handles", + "NGCP::Schema::Result::voip_sound_handles", + { id => "announcement_id" }, + { is_deferrable => 1, on_delete => "SET NULL", on_update => "CASCADE" }, +); + sub TO_JSON { my ($self) = @_; return { diff --git a/lib/NGCP/Schema/Result/voip_sound_handles.pm b/lib/NGCP/Schema/Result/voip_sound_handles.pm index e29d3574..09415263 100644 --- a/lib/NGCP/Schema/Result/voip_sound_handles.pm +++ b/lib/NGCP/Schema/Result/voip_sound_handles.pm @@ -37,6 +37,12 @@ __PACKAGE__->has_many( { "foreign.handle_id" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "voip_cf_destinations", + "NGCP::Schema::Result::voip_cf_destinations", + { "foreign.announcement_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); sub TO_JSON { my ($self) = @_;