diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index 80b1c046..d27198d9 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -126,6 +126,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "voip_cf_source_sets", + "NGCP::Schema::Result::voip_cf_source_sets", + { "foreign.subscriber_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "voip_contacts", "NGCP::Schema::Result::voip_contacts", @@ -469,6 +476,12 @@ Type: has_many Related object: L<NGCP::Schema::Result::voip_cf_time_sets> +=head2 voip_cf_source_sets + +Type: has_many + +Related object: L<NGCP::Schema::Result::voip_cf_source_sets> + =head2 voip_contacts Type: has_many diff --git a/lib/NGCP/Schema/Result/voip_cf_mappings.pm b/lib/NGCP/Schema/Result/voip_cf_mappings.pm index a633ec18..274111f5 100644 --- a/lib/NGCP/Schema/Result/voip_cf_mappings.pm +++ b/lib/NGCP/Schema/Result/voip_cf_mappings.pm @@ -44,6 +44,13 @@ __PACKAGE__->add_columns( is_foreign_key => 1, is_nullable => 1, }, + "source_set_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 1, + }, ); __PACKAGE__->set_primary_key("id"); @@ -79,6 +86,18 @@ __PACKAGE__->belongs_to( }, ); +__PACKAGE__->belongs_to( + "source_set", + "NGCP::Schema::Result::voip_cf_source_sets", + { id => "source_set_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + sub TO_JSON { my ($self) = @_; return { @@ -144,6 +163,13 @@ NGCP::Schema::Result::voip_cf_mappings is_foreign_key: 1 is_nullable: 1 +=head2 source_set_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 1 + =head1 PRIMARY KEY =over 4 @@ -171,3 +197,9 @@ Related object: L<NGCP::Schema::Result::provisioning_voip_subscribers> Type: belongs_to Related object: L<NGCP::Schema::Result::voip_cf_time_sets> + +=head2 source_set + +Type: belongs_to + +Related object: L<NGCP::Schema::Result::voip_cf_source_sets> diff --git a/lib/NGCP/Schema/Result/voip_cf_source_sets.pm b/lib/NGCP/Schema/Result/voip_cf_source_sets.pm new file mode 100644 index 00000000..67073422 --- /dev/null +++ b/lib/NGCP/Schema/Result/voip_cf_source_sets.pm @@ -0,0 +1,134 @@ +package NGCP::Schema::Result::voip_cf_source_sets; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); + +__PACKAGE__->table("provisioning.voip_cf_source_sets"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "subscriber_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 1, + }, + "name", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "subscriber", + "NGCP::Schema::Result::provisioning_voip_subscribers", + { id => "subscriber_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +__PACKAGE__->has_many( + "voip_cf_sources", + "NGCP::Schema::Result::voip_cf_sources", + { "foreign.source_set_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +__PACKAGE__->has_many( + "voip_cf_mappings", + "NGCP::Schema::Result::voip_cf_mappings", + { "foreign.source_set_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; +__END__ + +=encoding UTF-8 + +=head1 NAME + +NGCP::Schema::Result::voip_cf_source_sets + +=head1 COMPONENTS LOADED + +=over 4 + +=item * L<DBIx::Class::InflateColumn::DateTime> + +=item * L<DBIx::Class::Helper::Row::ToJSON> + +=back + +=head1 TABLE: C<provisioning.voip_cf_source_sets> + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + extra: {unsigned => 1} + is_auto_increment: 1 + is_nullable: 0 + +=head2 subscriber_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 1 + +=head2 name + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +=head1 PRIMARY KEY + +=over 4 + +=item * L</id> + +=back + +=head1 RELATIONS + +=head2 subscriber + +Type: belongs_to + +Related object: L<NGCP::Schema::Result::provisioning_voip_subscribers> + +=head2 voip_cf_sources + +Type: has_many + +Related object: L<NGCP::Schema::Result::voip_cf_sources> + +=head2 voip_cf_mappings + +Type: has_many + +Related object: L<NGCP::Schema::Result::voip_cf_mappings> diff --git a/lib/NGCP/Schema/Result/voip_cf_sources.pm b/lib/NGCP/Schema/Result/voip_cf_sources.pm new file mode 100644 index 00000000..56804893 --- /dev/null +++ b/lib/NGCP/Schema/Result/voip_cf_sources.pm @@ -0,0 +1,103 @@ +package NGCP::Schema::Result::voip_cf_sources; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); + +__PACKAGE__->table("provisioning.voip_cf_sources"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "source_set_id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_foreign_key => 1, + is_nullable => 0, + }, + "source", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + +__PACKAGE__->set_primary_key("id"); + +__PACKAGE__->belongs_to( + "source_set", + "NGCP::Schema::Result::voip_cf_source_sets", + { id => "source_set_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; +__END__ + +=encoding UTF-8 + +=head1 NAME + +NGCP::Schema::Result::voip_cf_sources + +=head1 COMPONENTS LOADED + +=over 4 + +=item * L<DBIx::Class::InflateColumn::DateTime> + +=item * L<DBIx::Class::Helper::Row::ToJSON> + +=back + +=head1 TABLE: C<provisioning.voip_cf_sources> + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + extra: {unsigned => 1} + is_auto_increment: 1 + is_nullable: 0 + +=head2 source_set_id + + data_type: 'integer' + extra: {unsigned => 1} + is_foreign_key: 1 + is_nullable: 0 + +=head2 source + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +=head1 PRIMARY KEY + +=over 4 + +=item * L</id> + +=back + +=head1 RELATIONS + +=head2 source_set + +Type: belongs_to + +Related object: L<NGCP::Schema::Result::voip_cf_source_sets>