[freeside-commits] freeside/bin merge-user,1.1,1.2
Mark Wells
mark at wavetail.420.am
Thu Jun 10 21:41:44 PDT 2010
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail.420.am:/tmp/cvs-serv19078/bin
Modified Files:
merge-user
Log Message:
RT#8691: script to merge usernums
Index: merge-user
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/merge-user,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- merge-user 11 Jun 2010 04:14:23 -0000 1.1
+++ merge-user 11 Jun 2010 04:41:42 -0000 1.2
@@ -10,7 +10,7 @@
my ($user, $from_usernum, $to_usernum, $go) = @ARGV;
die usage() if not ($user and $from_usernum and $to_usernum);
-$DRY_RUN = 0 if $go eq 'go';
+$DRY_RUN = 0 if defined($go) and $go eq 'go';
my $dbh = adminsuidsetup($user);
@@ -23,12 +23,19 @@
my $tables = FS::Schema::tables_hashref;
foreach my $table (keys %$tables) {
- next if $table =~ /^access/; # Don't try to merge these.
if( grep /^usernum$/, FS::Record::real_fields($table) ) {
+ next if $table eq 'access_user';
foreach ($table, "h_$table") {
print "$_: ";
- my $sql =
- "UPDATE $_ SET usernum = $to_usernum WHERE usernum = $from_usernum";
+ my $sql;
+ if( $table =~ /^access_(.*)$/ ) {
+ print "deleting ";
+ $sql = "DELETE FROM $_ WHERE usernum = $from_usernum";
+ }
+ else {
+ print "updating ";
+ $sql = "UPDATE $_ SET usernum = $to_usernum WHERE usernum = $from_usernum";
+ }
#print $sql;
my $sth = $dbh->prepare($sql);
$sth->execute;
More information about the freeside-commits
mailing list