From 49d653ace06705f575eb07a0e4861e55841bd52f Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Fri, 21 Oct 2016 18:51:50 +0200 Subject: [PATCH] TT#2369 add table sms_journal Change-Id: I7a4f6deed9df0ffb8481c6956b60ef2bd4d7b513 --- .../Result/provisioning_voip_subscribers.pm | 13 ++++ lib/NGCP/Schema/Result/sms_journal.pm | 76 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 lib/NGCP/Schema/Result/sms_journal.pm diff --git a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm index 557df165..0035771d 100644 --- a/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm +++ b/lib/NGCP/Schema/Result/provisioning_voip_subscribers.pm @@ -175,6 +175,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->has_many( + "sms_journals", + "NGCP::Schema::Result::sms_journal", + { 'foreign.subscriber_id' => 'self.id' }, + { cascade_copy => 0, cascade_delete => 0 }, +); + __PACKAGE__->has_many( "voip_mail_to_fax_secrets_renew_notify", "NGCP::Schema::Result::voip_mail_to_fax_secret_renew_notify", @@ -525,6 +532,12 @@ Type: has_many Related object: L +=head2 sms_journals + +Type: has_many + +Related object: L + =head2 voip_mail_to_fax_preference Type: might_have diff --git a/lib/NGCP/Schema/Result/sms_journal.pm b/lib/NGCP/Schema/Result/sms_journal.pm new file mode 100644 index 00000000..95bb7639 --- /dev/null +++ b/lib/NGCP/Schema/Result/sms_journal.pm @@ -0,0 +1,76 @@ +package NGCP::Schema::Result::sms_journal; +use Scalar::Util qw(blessed); +use parent 'DBIx::Class::Core'; + +our $VERSION = '2.007'; + +__PACKAGE__->load_components( + "InflateColumn::DateTime", + "Helper::Row::ToJSON", + "+NGCP::Schema::InflateColumn::DateTime::EpochMilli", +); + +__PACKAGE__->table("provisioning.sms_journal"); + +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + extra => { unsigned => 1 }, + is_auto_increment => 1, + is_nullable => 0, + }, + "subscriber_id", + { + data_type => "integer", + default_value => 0, + extra => { unsigned => 1 }, + is_nullable => 0, + }, + # "time", + # { data_type => "decimal", + # is_nullable => 0, + # size => [13, 3], + # inflate_datetime => 'epoch_milli' + # }, + "time", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, + "direction", + { + data_type => "enum", + extra => { list => ["in", "out" ] }, + is_nullable => 0, + }, + "caller", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "callee", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "text", + { data_type => "text", is_nullable => 0 }, + "reason", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "status", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, +); +__PACKAGE__->belongs_to( + "provisioning_voip_subscriber", + "NGCP::Schema::Result::provisioning_voip_subscribers", + { 'foreign.id' => 'self.subscriber_id' }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +__PACKAGE__->set_primary_key("id"); + +sub TO_JSON { + my ($self) = @_; + return { + map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method } + }; +} + +1; \ No newline at end of file