TT#5004 add autoprov_firmwares_data schema

* also remove data col from autoprof_firmwares

Change-Id: Ic0ee9ca8afa31d15c7d5c395bb829ed7e596f714
changes/26/9826/1
Kirill Solomko 9 years ago
parent bb1690cccc
commit 07ed8a1e48

@ -27,8 +27,6 @@ __PACKAGE__->add_columns(
{ data_type => "varchar", is_nullable => 1, size => 255 },
"filename",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"data",
{ data_type => "longblob", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
@ -40,6 +38,13 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->has_many(
"firmware_data",
"NGCP::Schema::Result::autoprov_firmwares_data",
{ "foreign.fw_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {
@ -84,11 +89,6 @@ NGCP::Schema::provisioning::Result::autoprov_firmwares
is_foreign_key: 1
is_nullable: 0
=head2 data
data_type: 'longblob'
is_nullable: 0
=head1 PRIMARY KEY
=over 4

@ -0,0 +1,102 @@
package NGCP::Schema::Result::autoprov_firmwares_data;
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_firmwares_data");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"fw_id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_foreign_key => 1,
is_nullable => 0,
},
"data",
{ data_type => "longblob", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
"firmware",
"NGCP::Schema::Result::autoprov_firmwares",
{ id => "fw_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::provisioning::Result::autoprov_firmwares
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::Helper::Row::ToJSON>
=back
=head1 TABLE: C<autoprov_firmwares>
=head1 ACCESSORS
=head2 id
data_type: 'integer'
extra: {unsigned => 1}
is_auto_increment: 1
is_nullable: 0
=head2 fw_id
data_type: 'integer'
extra: {unsigned => 1}
is_foreign_key: 1
is_nullable: 0
=head2 data
data_type: 'longblob'
is_nullable: 0
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=head1 RELATIONS
=head2 firmware
Type: belongs_to
Related object: L<NGCP::Schema::provisioning::Result::autoprov_firmwares>
Loading…
Cancel
Save