add svc_external
[freeside.git] / FS / bin / freeside-setup
index f6a543f..fce8bc7 100755 (executable)
@@ -111,8 +111,9 @@ my($dbdef) = new DBIx::DBSchema ( map {
 my $cust_main = $dbdef->table('cust_main');
 unless ($ship) { #remove ship_ from cust_main
   $cust_main->delcolumn($_) foreach ( grep /^ship_/, $cust_main->columns );
-} else { #add indices on ship_last and ship_company
-  push @{$cust_main->index->lol_ref}, ( ['ship_last'], ['ship_company'] ) 
+} else { #add indices
+  push @{$cust_main->index->lol_ref},
+    map { [ "ship_$_" ] } qw( last company daytime night fax );
 }
 
 #add radius attributes to svc_acct
@@ -290,6 +291,8 @@ foreach my $aref (
   [ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ],
   [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ],
   [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
+  [ 'DCRD', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
+  [ 'DCHK', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
 ) {
 
   my $part_bill_event = new FS::part_bill_event({
@@ -333,10 +336,13 @@ sub tables_hash_hack {
         'typenum',  'int',            '',     '',
         'freq',     'int',       'NULL', '',
         'prog',     @perl_type,
+        'disabled',     'char', 'NULL', 1,
+        'username', 'varchar',       'NULL',     $char_d,
+        '_password','varchar',       'NULL',     $char_d,
       ],
       'primary_key' => 'agentnum',
       'unique' => [],
-      'index' => [ ['typenum'] ],
+      'index' => [ ['typenum'], ['diabled'] ],
     },
 
     'agent_type' => {
@@ -370,7 +376,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'invnum',
       'unique' => [],
-      'index' => [ ['custnum'] ],
+      'index' => [ ['custnum'], ['_date'] ],
     },
 
     'cust_bill_event' => {
@@ -402,7 +408,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'eventpart',
       'unique' => [],
-      'index' => [ ['payby'] ],
+      'index' => [ ['payby'], ['disabled'], ],
     },
 
     'cust_bill_pkg' => {
@@ -420,6 +426,18 @@ sub tables_hash_hack {
       'index' => [ ['invnum'] ],
     },
 
+    'cust_bill_pkg_detail' => {
+      'columns' => [
+        'detailnum', 'serial', '', '',
+        'pkgnum',  'int', '', '',
+        'invnum',  'int', '', '',
+        'detail',  'varchar', '', $char_d,
+      ],
+      'primary_key' => 'detailnum',
+      'unique' => [],
+      'index' => [ [ 'pkgnum', 'invnum' ] ],
+    },
+
     'cust_credit' => {
       'columns' => [
         'crednum',  'serial', '', '',
@@ -456,7 +474,7 @@ sub tables_hash_hack {
         'last',     'varchar', '',     $char_d,
 #        'middle',   'varchar', 'NULL', $char_d,
         'first',    'varchar', '',     $char_d,
-        'ss',       'char', 'NULL', 11,
+        'ss',       'varchar', 'NULL', 11,
         'company',  'varchar', 'NULL', $char_d,
         'address1', 'varchar', '',     $char_d,
         'address2', 'varchar', 'NULL', $char_d,
@@ -484,6 +502,7 @@ sub tables_hash_hack {
         'ship_fax',      'varchar', 'NULL', 12,
         'payby',    'char', '',     4,
         'payinfo',  'varchar', 'NULL', $char_d,
+        'paycvv',   'varchar', 'NULL', 4,
         #'paydate',  @date_type,
         'paydate',  'varchar', 'NULL', 10,
         'payname',  'varchar', 'NULL', $char_d,
@@ -496,7 +515,9 @@ sub tables_hash_hack {
       'primary_key' => 'custnum',
       'unique' => [],
       #'index' => [ ['last'], ['company'] ],
-      'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ],
+      'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ],
+                   [ 'daytime' ], [ 'night' ], [ 'fax' ],
+                 ],
     },
 
     'cust_main_invoice' => {
@@ -522,6 +543,8 @@ sub tables_hash_hack {
         'exempt_amount', @money_type,
         'tax',      'real',  '',    '', #tax %
         'taxname',  'varchar',  'NULL',    $char_d,
+        'setuptax',  'char', 'NULL', 1, # Y = setup tax exempt
+        'recurtax',  'char', 'NULL', 1, # Y = recur tax exempt
       ],
       'primary_key' => 'taxnum',
       'unique' => [],
@@ -538,13 +561,13 @@ sub tables_hash_hack {
         '_date',    @date_type,
         'payby',    'char',   '',     4, # CARD/BILL/COMP, should be index into
                                          # payment type table.
-        'payinfo',  'varchar',   'NULL', 16,  #see cust_main above
+        'payinfo',  'varchar',   'NULL', $char_d,  #see cust_main above
         'paybatch', 'varchar',   'NULL', $char_d, #for auditing purposes.
         'closed',    'char', 'NULL', 1,
       ],
       'primary_key' => 'paynum',
       'unique' => [],
-      'index' => [ [ 'custnum' ], [ 'paybatch' ] ],
+      'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
     },
 
     'cust_bill_pay' => {
@@ -594,6 +617,7 @@ sub tables_hash_hack {
         'otaker',    'varchar', '', 32,
         'setup',     @date_type,
         'bill',      @date_type,
+        'last_bill', @date_type,
         'susp',      @date_type,
         'cancel',    @date_type,
         'expire',    @date_type,
@@ -615,7 +639,7 @@ sub tables_hash_hack {
         'reason',       'varchar',   '',   $char_d,
         'payby',        'char',   '',     4, # CARD/BILL/COMP, should be index
                                              # into payment type table.
-        'payinfo',      'varchar',   'NULL', 16,  #see cust_main above
+        'payinfo',      'varchar',   'NULL', $char_d,  #see cust_main above
         'paybatch',     'varchar',   'NULL', $char_d,
         'closed',    'char', 'NULL', 1,
       ],
@@ -655,7 +679,7 @@ sub tables_hash_hack {
         'pkg',        'varchar',   '',   $char_d,
         'comment',    'varchar',   '',   $char_d,
         'setup',      @perl_type,
-        'freq',       'int', '', '',  #billing frequency (months)
+        'freq',       'varchar',   '',   $char_d,  #billing frequency
         'recur',      @perl_type,
         'setuptax',  'char', 'NULL', 1,
         'recurtax',  'char', 'NULL', 1,
@@ -666,7 +690,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'pkgpart',
       'unique' => [],
-      'index' => [],
+      'index' => [ [ 'disabled' ], ],
     },
 
 #    'part_title' => {
@@ -694,10 +718,11 @@ sub tables_hash_hack {
       'columns' => [
         'refnum',   'serial',    '',   '',
         'referral', 'varchar',   '',   $char_d,
+        'disabled',     'char', 'NULL', 1,
       ],
       'primary_key' => 'refnum',
       'unique' => [],
-      'index' => [],
+      'index' => [ ['disabled'] ],
     },
 
     'part_svc' => {
@@ -709,7 +734,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'svcpart',
       'unique' => [],
-      'index' => [],
+      'index' => [ [ 'disabled' ] ],
     },
 
     'part_svc_column' => {
@@ -758,7 +783,7 @@ sub tables_hash_hack {
       'columns' => [
         'svcnum',    'int',    '',   '',
         'username',  'varchar',   '',   $username_len, #unique (& remove dup code)
-        '_password', 'varchar',   '',   50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34)
+        '_password', 'varchar',   '',   72, #13 for encryped pw's plus ' *SUSPENDED* (md5 passwords can be 34, blowfish 60)
         'sec_phrase', 'varchar',  'NULL',   $char_d,
         'popnum',    'int',    'NULL',   '',
         'uid',       'int', 'NULL',   '',
@@ -802,10 +827,12 @@ sub tables_hash_hack {
       'columns' => [
         'recnum',    'serial',     '',  '',
         'svcnum',    'int',     '',  '',
-        'reczone',   'varchar', '',  $char_d,
+        #'reczone',   'varchar', '',  $char_d,
+        'reczone',   'varchar', '',  255,
         'recaf',     'char',    '',  2,
-        'rectype',   'char',    '',  5,
-        'recdata',   'varchar', '',  $char_d,
+        'rectype',   'varchar',    '',  5,
+        #'recdata',   'varchar', '',  $char_d,
+        'recdata',   'varchar', '',  255,
       ],
       'primary_key' => 'recnum',
       'unique'      => [],
@@ -1007,76 +1034,101 @@ sub tables_hash_hack {
       'index'       => [],
     },
 
-    'ac_type' => {
+    'router' => {
       'columns' => [
-        'actypenum', 'serial', '', '',
-        'actypename', 'varchar', '', $char_d,
+        'routernum', 'serial', '', '',
+        'routername', 'varchar', '', $char_d,
+        'svcnum', 'int', 'NULL', '',
       ],
-      'primary_key' => 'actypenum',
+      'primary_key' => 'routernum',
       'unique'      => [],
       'index'       => [],
     },
 
-    'ac' => {
+    'part_svc_router' => {
       'columns' => [
-        'acnum', 'serial', '', '',
-        'actypenum', 'int', '', '',
-        'acname', 'varchar', '', $char_d,
+        'svcpart', 'int', '', '',
+       'routernum', 'int', '', '',
       ],
-      'primary_key' => 'acnum',
+      'primary_key' => '',
       'unique'      => [],
-      'index'       => [ [ 'actypenum' ] ],
+      'index'       => [],
     },
 
-    'part_ac_field' => {
+    'addr_block' => {
       'columns' => [
-        'acfieldpart', 'serial', '', '',
-        'actypenum', 'int', '', '',
-        'name', 'varchar', '', $char_d,
-        'ut_type', 'varchar', '', $char_d,
+        'blocknum', 'serial', '', '',
+       'routernum', 'int', '', '',
+        'ip_gateway', 'varchar', '', 15,
+        'ip_netmask', 'int', '', '',
       ],
-      'primary_key' => 'acfieldpart',
+      'primary_key' => 'blocknum',
+      'unique'      => [ [ 'blocknum', 'routernum' ] ],
+      'index'       => [],
+    },
+
+    'svc_broadband' => {
+      'columns' => [
+        'svcnum', 'int', '', '',
+        'blocknum', 'int', '', '',
+        'speed_up', 'int', '', '',
+        'speed_down', 'int', '', '',
+        'ip_addr', 'varchar', '', 15,
+      ],
+      'primary_key' => 'svcnum',
       'unique'      => [],
-      'index'       => [ [ 'actypenum' ] ],
+      'index'       => [],
     },
 
-    'ac_field' => {
+    'part_virtual_field' => {
       'columns' => [
-        'acfieldpart', 'int', '', '',
-        'acnum', 'int', '', '',
-        'value', 'text', '', '',
+        'vfieldpart', 'int', '', '',
+        'dbtable', 'varchar', '', 32,
+        'name', 'varchar', '', 32,
+        'check_block', 'text', 'NULL', '',
+        'length', 'int', 'NULL', '',
+        'list_source', 'text', 'NULL', '',
+        'label', 'varchar', 'NULL', 80,
       ],
-      'primary_key' => '',
-      'unique'      => [ [ 'acfieldpart', 'acnum' ] ],
-      'index'       => [ [ 'acnum' ] ],
+      'primary_key' => 'vfieldpart',
+      'unique' => [],
+      'index' => [],
     },
 
-    'ac_block' => {
+    'virtual_field' => {
       'columns' => [
-        'acnum', 'int', '', '',
-        'ip_gateway', 'varchar', '', 15,
-        'ip_netmask', 'int', '', '',
+        'recnum', 'int', '', '',
+        'vfieldpart', 'int', '', '',
+        'value', 'varchar', '', 128,
       ],
       'primary_key' => '',
-      'unique'      => [],
-      'index'       => [ [ 'acnum' ] ],
+      'unique' => [ [ 'vfieldpart', 'recnum' ] ],
+      'index' => [],
     },
 
-    'svc_broadband' => {
+    'acct_snarf' => {
+      'columns' => [
+        'snarfnum',  'int', '', '',
+        'svcnum',    'int', '', '',
+        'machine',   'varchar', '', 255,
+        'protocol',  'varchar', '', $char_d,
+        'username',  'varchar', '', $char_d,
+        '_password', 'varchar', '', $char_d,
+      ],
+      'primary_key' => 'snarfnum',
+      'unique' => [],
+      'index'  => [ [ 'svcnum' ] ],
+    },
+
+    'svc_external' => {
       'columns' => [
         'svcnum', 'int', '', '',
-        'actypenum', 'int', '', '',
-        'speed_up', 'int', '', '',
-        'speed_down', 'int', '', '',
-        'acnum', 'int', '', '',
-        'ip_addr', 'varchar', '', 15,
-        'ip_netmask', 'int', '', '',
-        'mac_addr', 'char', '', 17,
-        'location', 'varchar', '', $char_d,
+        'id',     'int', '', '',
+        'title',  'varchar', 'NULL', $char_d,
       ],
       'primary_key' => 'svcnum',
       'unique'      => [],
-      'index'       => [ [ 'actypenum' ] ],
+      'index'       => [],
     },
 
   );