From 5cb7bcbe587c113fead03e5c7c95299cbb9a832f Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 17 Sep 2021 17:25:10 +0200 Subject: [PATCH] TT#66577 sems_registrations, voip_peer_hosts * add new columns and a primary key to sems_registrations * voip_peer_hosts add might_have relation to kamailio.lcr_gw * update kamailio.subscriber table fields * change provisioning_voip_subscriber -> kamailio_subscriber relation from has_many to has_one Change-Id: I96e4aa7d68c09146d373e7300a762fd1c7b3f7da --- .../Result/provisioning_voip_subscribers.pm | 2 +- lib/NGCP/Schema/Result/sems_registrations.pm | 43 +++++++++++++++++-- lib/NGCP/Schema/Result/subscriber.pm | 6 +-- lib/NGCP/Schema/Result/voip_peer_hosts.pm | 6 +++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index 41611849..5a15ac9a 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -312,7 +312,7 @@ __PACKAGE__->belongs_to( { cascade_copy => 0, cascade_delete => 0 }, ); -__PACKAGE__->has_many( +__PACKAGE__->has_one( "kamailio_subscriber", 'NGCP::Schema::Result::subscriber', { 'foreign.uuid' => 'self.uuid' }, diff --git a/lib/NGCP/Schema/Result/sems_registrations.pm b/lib/NGCP/Schema/Result/sems_registrations.pm index a110afa0..b9b34479 100644 --- a/lib/NGCP/Schema/Result/sems_registrations.pm +++ b/lib/NGCP/Schema/Result/sems_registrations.pm @@ -13,10 +13,33 @@ __PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); __PACKAGE__->table("kamailio.sems_registrations"); __PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, "subscriber_id", - { data_type => "integer", is_nullable => 0 }, + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 1, + }, + "peer_host_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 1, + }, "registration_status", - { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + { + data_type => "tinyint", + default_value => 0, + is_nullable => 0 + }, "last_registration", { data_type => "datetime", @@ -37,7 +60,21 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 512 }, ); -__PACKAGE__->set_primary_key("subscriber_id"); +__PACKAGE__->belongs_to( + "subscriber", + "NGCP::Schema::Result::subscriber", + { id => "subscriber_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +__PACKAGE__->belongs_to( + "lcr_gw", + "NGCP::Schema::Result::lcr_gw", + { id => "peer_host_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +__PACKAGE__->set_primary_key("id"); sub TO_JSON { my ($self) = @_; diff --git a/lib/NGCP/Schema/Result/subscriber.pm b/lib/NGCP/Schema/Result/subscriber.pm index 64552986..08f58d02 100644 --- a/lib/NGCP/Schema/Result/subscriber.pm +++ b/lib/NGCP/Schema/Result/subscriber.pm @@ -22,18 +22,14 @@ __PACKAGE__->add_columns( }, "username", { data_type => "varchar", default_value => "", is_nullable => 0, size => 64 }, - "domain", - { data_type => "varchar", default_value => "", is_nullable => 0, size => 64 }, "password", { data_type => "varchar", default_value => "", is_nullable => 0, size => 40 }, - "email_address", + "domain", { data_type => "varchar", default_value => "", is_nullable => 0, size => 64 }, "ha1", { data_type => "varchar", default_value => "", is_nullable => 0, size => 64 }, "ha1b", { data_type => "varchar", default_value => "", is_nullable => 0, size => 64 }, - "rpid", - { data_type => "varchar", is_nullable => 1, size => 64 }, "uuid", { data_type => "char", is_nullable => 0, size => 36 }, "timezone", diff --git a/lib/NGCP/Schema/Result/voip_peer_hosts.pm b/lib/NGCP/Schema/Result/voip_peer_hosts.pm index 9d531e83..859b3eb8 100644 --- a/lib/NGCP/Schema/Result/voip_peer_hosts.pm +++ b/lib/NGCP/Schema/Result/voip_peer_hosts.pm @@ -67,6 +67,12 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->might_have( + "lcr_gw", + "NGCP::Schema::Result::lcr_gw", + { "foreign.flags" => "self.id" }, +); + sub TO_JSON { my ($self) = @_; return {