TT#6735 TT#7030 TT#5850 accountin.events entity-attribute-value models

Change-Id: I5b336f291a2c449ecd1f678ab7405a0bde4c318f
changes/65/9965/8
Rene Krenn 9 years ago
parent e95561ac82
commit 34b77a65da

@ -51,6 +51,20 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
"relation_data",
"NGCP::Schema::Result::events_relation_data",
{ "foreign.event_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"tag_data",
"NGCP::Schema::Result::events_tag_data",
{ "foreign.event_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

@ -0,0 +1,49 @@
package NGCP::Schema::Result::events_relation;
use Scalar::Util qw(blessed);
use parent 'DBIx::Class::Core';
our $VERSION = '2.007';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"Helper::Row::ToJSON",
);
__PACKAGE__->table("accounting.events_relation");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"type",
{
data_type => "enum",
extra => { list => [
'primary_number_id',
'subscriber_profile_id',
'subscriber_profile_set_id',
'pilot_primary_number_id',
'pilot_subscriber_profile_id',
'pilot_subscriber_profile_set_id',
] },
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("erc_type_idx", ["type"]);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;

@ -0,0 +1,52 @@
package NGCP::Schema::Result::events_relation_data;
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("accounting.events_relation_data");
__PACKAGE__->add_columns(
"event_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_nullable => 0,
},
"relation_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_nullable => 0,
},
"val",
{ data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 },
"event_timestamp",
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
);
__PACKAGE__->set_primary_key("event_id","relation_id","event_timestamp");
__PACKAGE__->has_one(
"relation",
'NGCP::Schema::Result::events_relation',
{ 'foreign.id' => 'self.relation_id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;

@ -0,0 +1,53 @@
package NGCP::Schema::Result::events_tag;
use Scalar::Util qw(blessed);
use parent 'DBIx::Class::Core';
our $VERSION = '2.007';
__PACKAGE__->load_components(
"InflateColumn::DateTime",
"Helper::Row::ToJSON",
);
__PACKAGE__->table("accounting.events_tag");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"type",
{
data_type => "enum",
extra => { list => [
'primary_number_cc',
'primary_number_ac',
'primary_number_sn',
'pilot_primary_number_cc',
'pilot_primary_number_ac',
'pilot_primary_number_sn',
'subscriber_profile_name',
'subscriber_profile_set_name',
'pilot_subscriber_profile_name',
'pilot_subscriber_profile_set_name',
] },
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("etc_type_idx", ["type"]);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;

@ -0,0 +1,52 @@
package NGCP::Schema::Result::events_tag_data;
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("accounting.events_tag_data");
__PACKAGE__->add_columns(
"event_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_nullable => 0,
},
"tag_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_nullable => 0,
},
"val",
{ data_type => "text", is_nullable => 0 },
"event_timestamp",
{ data_type => "decimal", is_nullable => 0, size => [13, 3], inflate_datetime => 'epoch_milli' },
);
__PACKAGE__->set_primary_key("event_id","tag_id","event_timestamp");
__PACKAGE__->has_one(
"relation",
'NGCP::Schema::Result::events_tag',
{ 'foreign.id' => 'self.tag_id' },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
};
}
1;
Loading…
Cancel
Save