4 use FS::UID qw(adminsuidsetup);
5 use FS::Record qw(qsearch fields);
8 my $user = shift or die &usage;
9 my $dbh = adminsuidsetup $user;
11 my $oldAutoCommit = $FS::UID::AutoCommit;
12 local $FS::UID::AutoCommit = 0;
14 foreach my $part_svc ( qsearch('part_svc', {} ) ) {
16 grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$_.'_flag') ) }
17 fields($part_svc->svcdb)
19 my $flag = $part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag');
20 if ( uc($flag) =~ /^([DF])$/ ) {
21 my $part_svc_column = new FS::part_svc_column {
22 'svcpart' => $part_svc->svcpart,
23 'columnname' => $field,
25 'columnvalue' => $part_svc->getfield($part_svc->svcdb.'__'.$field),
27 my $error = $part_svc_column->insert;
29 $dbh->rollback if $oldAutoCommit;
36 $dbh->commit or die $dbh->errstr;
39 die "Usage:\n fs-migrate-part_svc user\n";