quoting fix for billing expressions
[freeside.git] / bin / fs-setup
index 37ecf1b..c60181b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.89 2002-04-20 06:33:03 ivan Exp $
+# $Id: fs-setup,v 1.96.4.6 2002-12-24 22:41:21 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -106,8 +106,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
@@ -165,6 +166,11 @@ foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) {
   my $tableobj = $dbdef->table($table)
     or die "unknown table $table";
 
+  die "unique->lol_ref undefined for $table"
+    unless defined $tableobj->unique->lol_ref;
+  die "index->lol_ref undefined for $table"
+    unless defined $tableobj->index->lol_ref;
+
   my $h_tableobj = DBIx::DBSchema::Table->new( {
     name        => "h_$table",
     primary_key => 'historynum',
@@ -336,7 +342,7 @@ sub tables_hash_hack {
         'prog',     @perl_type,
       ],
       'primary_key' => 'agentnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['typenum'] ],
     },
 
@@ -346,8 +352,8 @@ sub tables_hash_hack {
         'atype',     'varchar', '', $char_d,
       ],
       'primary_key' => 'typenum',
-      'unique' => [ [] ],
-      'index' => [ [] ],
+      'unique' => [],
+      'index' => [],
     },
 
     'type_pkgs' => {
@@ -370,7 +376,7 @@ sub tables_hash_hack {
         'closed',    'char', 'NULL', 1,
       ],
       'primary_key' => 'invnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['custnum'] ],
     },
 
@@ -402,7 +408,7 @@ sub tables_hash_hack {
         'disabled',     'char', 'NULL', 1,
       ],
       'primary_key' => 'eventpart',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['payby'] ],
     },
 
@@ -431,7 +437,7 @@ sub tables_hash_hack {
         'closed',    'char', 'NULL', 1,
       ],
       'primary_key' => 'crednum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['custnum'] ],
     },
 
@@ -444,7 +450,7 @@ sub tables_hash_hack {
         'amount',   @money_type,
       ],
       'primary_key' => 'creditbillnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['crednum'], ['invnum'] ],
     },
 
@@ -494,9 +500,11 @@ sub tables_hash_hack {
         'comments', 'text', 'NULL', '',
       ],
       'primary_key' => 'custnum',
-      'unique' => [ [] ],
+      'unique' => [],
       #'index' => [ ['last'], ['company'] ],
-      'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ],
+      'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ],
+                   [ 'daytime' ], [ 'night' ], [ 'fax' ],
+                 ],
     },
 
     'cust_main_invoice' => {
@@ -506,7 +514,7 @@ sub tables_hash_hack {
         'dest',     'varchar', '',  $char_d,
       ],
       'primary_key' => 'destnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['custnum'], ],
     },
 
@@ -518,12 +526,14 @@ sub tables_hash_hack {
         'state',    'varchar',  'NULL',    $char_d,
         'county',   'varchar',  'NULL',    $char_d,
         'country',  'char',  '', 2, 
+        'taxclass',   'varchar', 'NULL', $char_d,
+        'exempt_amount', @money_type,
         'tax',      'real',  '',    '', #tax %
       ],
       'primary_key' => 'taxnum',
-      'unique' => [ [] ],
+      'unique' => [],
   #    'unique' => [ ['taxnum'], ['state', 'county'] ],
-      'index' => [ [] ],
+      'index' => [],
     },
 
     'cust_pay' => {
@@ -535,12 +545,12 @@ 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' => [ [] ],
+      'unique' => [],
       'index' => [ [ 'custnum' ], [ 'paybatch' ] ],
     },
 
@@ -553,7 +563,7 @@ sub tables_hash_hack {
         '_date',   @date_type
       ],
       'primary_key' => 'billpaynum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ [ 'paynum' ], [ 'invnum' ] ],
     },
 
@@ -568,7 +578,7 @@ sub tables_hash_hack {
         'address1', 'varchar', '',     $char_d,
         'address2', 'varchar', 'NULL', $char_d,
         'city',     'varchar', '',     $char_d,
-        'state',    'varchar', '',     $char_d,
+        'state',    'varchar', 'NULL', $char_d,
         'zip',      'varchar', '',     10,
         'country',  'char', '',     2,
 #        'trancode', 'int', '', '',
@@ -579,7 +589,7 @@ sub tables_hash_hack {
         'amount',   @money_type,
       ],
       'primary_key' => 'paybatchnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['invnum'], ['custnum'] ],
     },
 
@@ -597,7 +607,7 @@ sub tables_hash_hack {
         'manual_flag', 'char', 'NULL', 1,
       ],
       'primary_key' => 'pkgnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['custnum'] ],
     },
 
@@ -612,13 +622,13 @@ 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,
       ],
       'primary_key' => 'refundnum',
-      'unique' => [ [] ],
-      'index' => [ [] ],
+      'unique' => [],
+      'index' => [],
     },
 
     'cust_credit_refund' => {
@@ -630,7 +640,7 @@ sub tables_hash_hack {
         '_date',   @date_type
       ],
       'primary_key' => 'creditrefundnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ [ 'crednum', 'refundnum' ] ],
     },
 
@@ -642,7 +652,7 @@ sub tables_hash_hack {
         'svcpart',   'int',    '',   '',
       ],
       'primary_key' => 'svcnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
     },
 
@@ -659,10 +669,11 @@ sub tables_hash_hack {
         'plan',       'varchar', 'NULL', $char_d,
         'plandata',   'text', 'NULL', '',
         'disabled',   'char', 'NULL', 1,
+        'taxclass',   'varchar', 'NULL', $char_d,
       ],
       'primary_key' => 'pkgpart',
-      'unique' => [ [] ],
-      'index' => [ [] ],
+      'unique' => [],
+      'index' => [ [ 'disabled' ] ],
     },
 
 #    'part_title' => {
@@ -692,8 +703,8 @@ sub tables_hash_hack {
         'referral', 'varchar',   '',   $char_d,
       ],
       'primary_key' => 'refnum',
-      'unique' => [ [] ],
-      'index' => [ [] ],
+      'unique' => [],
+      'index' => [],
     },
 
     'part_svc' => {
@@ -704,8 +715,8 @@ sub tables_hash_hack {
         'disabled',   'char',  'NULL',   1,
       ],
       'primary_key' => 'svcpart',
-      'unique' => [ [] ],
-      'index' => [ [] ],
+      'unique' => [],
+      'index' => [ [ 'disabled' ] ],
     },
 
     'part_svc_column' => {
@@ -732,7 +743,7 @@ sub tables_hash_hack {
         'loc',       'char',   'NULL',   4, #NULL for legacy purposes
       ],
       'primary_key' => 'popnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ [ 'state' ] ],
     },
 
@@ -746,7 +757,7 @@ sub tables_hash_hack {
         'nxx',       'char',    '',     3,
       ],
       'primary_key' => 'localnum',
-      'unique' => [ [] ],
+      'unique' => [],
       'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ],
     },
 
@@ -768,7 +779,8 @@ sub tables_hash_hack {
         'domsvc',    'int', '',   '',
       ],
       'primary_key' => 'svcnum',
-      'unique' => [ [ 'username', 'domsvc' ] ],
+      #'unique' => [ [ 'username', 'domsvc' ] ],
+      'unique' => [],
       'index' => [ ['username'], ['domsvc'] ],
     },
 
@@ -802,20 +814,22 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'svcnum',
       'unique' => [ ['domain'] ],
-      'index' => [ [] ],
+      'index' => [],
     },
 
     'domain_record' => {
       'columns' => [
         'recnum',    'int',     '',  '',
         'svcnum',    'int',     '',  '',
-        'reczone',   'varchar', '',  $char_d,
+        #'reczone',   'varchar', '',  $char_d,
+        'reczone',   'varchar', '',  255,
         'recaf',     'char',    '',  2,
         'rectype',   'char',    '',  5,
-        'recdata',   'varchar', '',  $char_d,
+        #'recdata',   'varchar', '',  $char_d,
+        'recdata',   'varchar', '',  255,
       ],
       'primary_key' => 'recnum',
-      'unique'      => [ [] ],
+      'unique'      => [],
       'index'       => [ ['svcnum'] ],
     },
 
@@ -827,7 +841,7 @@ sub tables_hash_hack {
         'dst',      'varchar',    'NULL',  $char_d,
       ],
       'primary_key' => 'svcnum',
-      'unique'      => [ [] ],
+      'unique'      => [],
       'index'       => [ ['srcsvc'], ['dstsvc'] ],
     },
 
@@ -838,8 +852,8 @@ sub tables_hash_hack {
         'usersvc',  'int',    '',  '',
       ],
       'primary_key' => 'svcnum',
-      'unique'      => [ [] ],
-      'index'       => [ [] ],
+      'unique'      => [],
+      'index'       => [],
     },
 
     #'svc_wo' => {
@@ -864,7 +878,7 @@ sub tables_hash_hack {
       ],
       'primary_key' => 'prepaynum',
       'unique'      => [ ['identifier'] ],
-      'index'       => [ [] ],
+      'index'       => [],
     },
 
     'port' => {
@@ -930,6 +944,17 @@ sub tables_hash_hack {
       'index'       => [ [ 'jobnum' ] ],
     },
 
+    'queue_depend' => {
+      'columns' => [
+        'dependnum', 'int', '', '',
+        'jobnum', 'int', '', '',
+        'depend_jobnum', 'int', '', '',
+      ],
+      'primary_key' => 'dependnum',
+      'unique'      => [],
+      'index'       => [ [ 'jobnum' ], [ 'depend_jobnum' ] ],
+    },
+
     'export_svc' => {
       'columns' => [
         'exportsvcnum' => 'int', '', '',
@@ -989,6 +1014,22 @@ sub tables_hash_hack {
       'index'       => [],
     },
 
+    'cust_tax_exempt' => {
+      'columns' => [
+        'exemptnum', 'int', '', '',
+        'custnum',   'int', '', '',
+        'taxnum',    'int', '', '',
+        'year',      'int', '', '',
+        'month',     'int', '', '',
+        'amount',   @money_type,
+      ],
+      'primary_key' => 'exemptnum',
+      'unique'      => [ [ 'custnum', 'taxnum', 'year', 'month' ] ],
+      'index'       => [],
+    },
+
+
+
   );
 
   %tables;