5 use FS::UID qw( adminsuidsetup );
6 use FS::Record qw( qsearchs );
7 use FS::h_cust_location;
10 adminsuidsetup shift or &usage;
11 my $start = shift or &usage;
12 my $end = shift or &usage;
14 for my $locationnum ( $start .. $end ) {
16 my $h_cust_location = qsearchs({
17 'table' => 'h_cust_location',
18 'hashref' => { 'locationnum' => $locationnum, },
19 'extra_sql' => " AND ( history_action = 'insert' OR history_action = 'replace_new' )",
20 'order_by' => 'ORDER BY historynum DESC LIMIT 1',
22 or die "h_cust_location for $locationnum not found\n";
24 warn "recovering cust_locaiton $locationnum\n";
25 my $cust_location = new FS::cust_location { $h_cust_location->hash };
26 my $error = $cust_location->insert;
32 die "Usage: recover-cust_location username start_locationnum end_locationnum\n";