MT#9177 Version of separate table per sync model.

Not sure that it will be really good model.
Just save before change to all models properties in one table.
changes/75/675/1
Irina Peshinskaya 11 years ago
parent c965a9f030
commit ceea3ff4eb

@ -30,21 +30,7 @@ __PACKAGE__->add_columns(
{ data_type => "mediumblob", is_nullable => 1 },
"mac_image_type",
{ data_type => "varchar", is_nullable => 0, size => 32 },
"sync_uri",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"sync_method",
{
data_type => "enum",
default_value => "GET",
extra => { list => ["GET", "POST"] },
is_nullable => 0,
},
"sync_params",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"security_handler",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);
);
__PACKAGE__->belongs_to(
"reseller",
@ -79,6 +65,13 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"autoprov_sync_cisco",
"NGCP::Schema::Result::autoprov_sync_cisco",
{ "foreign.device_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->set_primary_key("id");
sub TO_JSON {

@ -0,0 +1,101 @@
package NGCP::Schema::Result::autoprov_sync_cisco;
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_sync_cisco");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
extra => { unsigned => 1 },
is_auto_increment => 1,
is_nullable => 0,
},
"device_id",
{ data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 },
"sync_uri",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"sync_method",
{
data_type => "enum",
default_value => "GET",
extra => { list => ["GET", "POST"] },
is_nullable => 0,
},
"sync_params",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"security_handler",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);
__PACKAGE__->belongs_to(
"device",
"NGCP::Schema::Result::autoprov_devices",
{ id => "device_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
}
);
__PACKAGE__->set_primary_key("id");
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_sync_cisco
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::Helper::Row::ToJSON>
=back
=head1 TABLE: C<autoprov_sync_cisco>
=head1 ACCESSORS
=head2 id
data_type: 'integer'
extra: {unsigned => 1}
is_auto_increment: 1
is_nullable: 0
=head2 device_id
data_type: 'integer'
extra: {unsigned => 1}
is_nullable: 0
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
Loading…
Cancel
Save