+#class method
+sub _upgrade_data {
+ my $class = shift;
+
+ local($FS::svc_Common::noexport_hack) = 1;
+
+ # set routernum to addr_block.routernum
+ foreach my $self (qsearch('svc_broadband', {
+ blocknum => {op => '!=', value => ''},
+ routernum => ''
+ })) {
+ my $addr_block = $self->addr_block;
+ if ( !$addr_block ) {
+ # super paranoid mode
+ warn "WARNING: svcnum ".$self->svcnum." is assigned to addr_block ".$self->blocknum.", which does not exist; skipped.\n";
+ next;
+ }
+ my $ip_addr = $self->ip_addr;
+ my $routernum = $addr_block->routernum;
+ if ( $routernum ) {
+ $self->set(routernum => $routernum);
+ my $error = $self->check;
+ # sanity check: don't allow this to change IP address or block
+ # (other than setting blocknum to null for a non-auto-assigned router)
+ if ( $self->ip_addr ne $ip_addr
+ or ($self->blocknum and $self->blocknum != $addr_block->blocknum)) {
+ warn "WARNING: Upgrading service ".$self->svcnum." would change its block/address; skipped.\n";
+ next;
+ }
+
+ $error ||= $self->replace;
+ warn "WARNING: error assigning routernum $routernum to service ".$self->svcnum.
+ ":\n$error; skipped\n"
+ if $error;
+ }
+ else {
+ warn "svcnum ".$self->svcnum.
+ ": no routernum in address block ".$addr_block->cidr.", skipped\n";
+ }
+ }