adding rt-drop-tables
authorivan <ivan>
Mon, 11 Jul 2005 14:15:09 +0000 (14:15 +0000)
committerivan <ivan>
Mon, 11 Jul 2005 14:15:09 +0000 (14:15 +0000)
bin/rate.import
bin/rt-drop-tables [new file with mode: 0755]

index 29b5239..fdd756d 100755 (executable)
@@ -59,15 +59,25 @@ while ( my $row = $sth->fetchrow_hashref ) {
     $prefix = $2;
   }
 
-  my @rate_prefix = map { 
-                          #warn $row->{'Country'}. ": $prefixprefix$_\n";
-                          new FS::rate_prefix {
-                            'countrycode' => $row->{'Code'},
-                            'npa'         => $prefixprefix.$_,
-                          };
-                        }
-                        split(/\s*[;,]\s*/, $prefix);
-
+  my @rate_prefix = ();
+  if ( $prefix =~ /\d/ ) {
+
+    @rate_prefix = map { 
+                         #warn $row->{'Country'}. ": $prefixprefix$_\n";
+                         new FS::rate_prefix {
+                           'countrycode' => $row->{'Code'},
+                           'npa'         => $prefixprefix.$_,
+                         };
+                       }
+                       split(/\s*[;,]\s*/, $prefix);
+
+  } else {
+    @rate_prefix = ( new FS::rate_prefix {
+                       'countycode' => $row->{'Code'},
+                       'npa'        => '',
+                     };
+                   );
+  }
 
   my $dest_detail = new FS::rate_detail {
                                           'ratenum'         => $ratenum,
diff --git a/bin/rt-drop-tables b/bin/rt-drop-tables
new file mode 100755 (executable)
index 0000000..b027542
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+my @tables = qw(
+Attachments 
+Queues 
+Links 
+Principals 
+Groups 
+ScripConditions 
+Transactions 
+Scrips 
+ACL 
+GroupMembers 
+CachedGroupMembers 
+Users 
+Tickets 
+ScripActions 
+Templates 
+TicketCustomFieldValues 
+CustomFields 
+CustomFieldValues 
+sessions 
+);
+
+foreach my $table ( @tables ) {
+  print "drop table $table;\n";
+  print "drop sequence ${table}_id_seq;\n";
+}
+