ngcp-schema/lib/NGCP/Schema/Result/autoprov_device_line_annota...

77 lines
1.6 KiB

package NGCP::Schema::Result::autoprov_device_line_annotations;
use strict;
use warnings;
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.autoprov_device_line_annotations");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"range_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 0,
},
"line_index",
{
data_type => "integer",
default_value => 0,
extra => { unsigned => 1 },
is_nullable => 0,
},
"x",
{
data_type => "integer",
default_value => 0,
extra => { unsigned => 1 },
is_nullable => 0,
},
"y",
{
data_type => "integer",
default_value => 0,
extra => { unsigned => 1 },
is_nullable => 0,
},
"position",
{
data_type => "enum",
default_value => "top",
extra => { list => ["top", "bottom", "left", "right", "bottomleft", "bottomright", "topleft", "topright"] },
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
"range",
"NGCP::Schema::Result::autoprov_device_line_ranges",
{ id => "range_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;