svc_hardware uniqueness checks, RT#81534
[freeside.git] / FS / FS / Schema.pm
index c27b727..6ea0609 100644 (file)
@@ -203,6 +203,7 @@ sub dbdef_dist {
            && ! /^log(_context)?$/
            && ! /^(legacy_cust_history|cacti_page|template_image|access_user_log)$/
            && ( ! /^queue(_arg|_depend|_stat)?$/ || ! $opt->{'queue-no_history'} )
+           && ! /^addr_status$/
            && ! $tables_hashref_torrus->{$_}
          }
       $dbdef->tables
@@ -494,8 +495,44 @@ sub tables_hashref {
 
   my $username_len = 64; #usernamemax config file
 
-    # name type nullability length default local
+  # Return a hashref defining the entire application database schema
+  # Each key of the hashref contains a structure describing a database table
+  #
+  # table_name => {
+  #   columns      => [...],
+  #   primary_key  => 'column',
+  #   unique       => [column,column,...],
+  #   index        => [[column],[column,column],...],
+  #   foreign_keys => [{...},{...},...],
+  # }
+  #
+  #
+  # columns => [
+  #
+  #   'column_name',
+  #
+  #   'column_type',
+  #
+  #   'NULL' or '',   # 'NULL' : Allow null values
+  #                   # ''     : Disallow null values
+  #
+  #   'length',       # Column size value.  eg:
+  #                   # 40     : VARCHAR(40)
+  #                   # '10,2' : FLOAT(10,2)
+  #
+  #   'default',      # Default column value for a new record
+  #                   # (Unclear if setting this to '' results in a default
+  #                   #  value of NULL or empty string?)
+  #
+  #   '',             # local ?
+  #
+  #   name, type, nullability, length, default, local,
+  #   name, type, nullability, length, default, local,
+  #   ...
+  #
+  # ],
 
+  # name type nullability length default local
   return {
 
     'agent' => {
@@ -694,6 +731,7 @@ sub tables_hashref {
         'statementnum', 'int', 'NULL', '', '', '', #invoice aggregate statements
         'agent_invid',  'int', 'NULL', '', '', '', #(varchar?) importing legacy
         'promised_date', @date_type,       '', '',
+        'taxengine_request', 'text', 'NULL', '', '', '',
         
         'pending',     'char', 'NULL',  1, '', '',
       ],
@@ -731,6 +769,7 @@ sub tables_hashref {
         'statementnum', 'int', 'NULL', '', '', '', #invoice aggregate statements
         'agent_invid',  'int', 'NULL', '', '', '', #(varchar?) importing legacy
         'promised_date', @date_type,       '', '',
+        'taxengine_request', 'text', 'NULL', '', '', '',
 
         #void fields
         'void_date', @date_type, '', '', 
@@ -923,12 +962,13 @@ sub tables_hashref {
         '_date',     @date_type, '', '', 
         'status', 'varchar', '', $char_d, '', '', 
         'statustext', 'text', 'NULL', '', '', '', 
+        'no_action',  'char', 'NULL',  1, '', '',
       ],
       'primary_key'  => 'eventnum',
       #no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
       'unique'       => [],
       'index'        => [ ['eventpart'], ['tablenum'], ['status'],
-                          ['statustext'], ['_date'],
+                          ['statustext'], ['_date'], ['no_action'],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'eventpart' ],
@@ -1360,6 +1400,7 @@ sub tables_hashref {
         'commission_agentnum', 'int', 'NULL', '', '', '', #
         'commission_salesnum', 'int', 'NULL', '', '', '', #
         'commission_pkgnum',   'int', 'NULL', '', '', '', #
+        'commission_invnum',   'int', 'NULL', '', '', '',
         'credbatch',    'varchar', 'NULL', $char_d, '', '',
       ],
       'primary_key'  => 'crednum',
@@ -1395,6 +1436,10 @@ sub tables_hashref {
                             table      => 'cust_pkg',
                             references => [ 'pkgnum' ],
                           },
+                          { columns    => [ 'commission_invnum' ],
+                            table      => 'cust_bill',
+                            references => [ 'invnum' ],
+                          },
                         ],
     },
 
@@ -1416,6 +1461,7 @@ sub tables_hashref {
         'commission_agentnum', 'int', 'NULL', '', '', '',
         'commission_salesnum', 'int', 'NULL', '', '', '',
         'commission_pkgnum',   'int', 'NULL', '', '', '',
+        'commission_invnum',   'int', 'NULL', '', '', '',
         #void fields
         'void_date',  @date_type,                  '', '', 
         'void_reason', 'varchar', 'NULL', $char_d, '', '', 
@@ -1455,6 +1501,10 @@ sub tables_hashref {
                             table      => 'cust_pkg',
                             references => [ 'pkgnum' ],
                           },
+                          { columns    => [ 'commission_invnum' ],
+                            table      => 'cust_bill',
+                            references => [ 'invnum' ],
+                          },
                           { columns    => [ 'void_reasonnum' ],
                             table      => 'reason',
                             references => [ 'reasonnum' ],
@@ -1608,6 +1658,8 @@ sub tables_hashref {
         'ship_mobile',   'varchar', 'NULL', 12, '', '', 
         'currency',         'char', 'NULL',  3, '', '',
 
+        'is_tokenized', 'char', 'NULL', '1', '', '',
+
         'geocode',  'varchar', 'NULL', 20,  '', '',
         'censustract', 'varchar', 'NULL', 20,  '', '', # 7 to save space?
         'censusyear', 'char', 'NULL', 4, '', '',
@@ -1629,6 +1681,7 @@ sub tables_hashref {
         'accountcode_cdr', 'char', 'NULL', 1, '', '',
         'billday',   'int', 'NULL', '', '', '',
         'prorate_day',   'int', 'NULL', '', '', '',
+        'force_prorate_day', 'char', 'NULL', 1, '', '',
         'edit_subject', 'char', 'NULL', 1, '', '',
         'locale', 'varchar', 'NULL', 16, '', '', 
         'calling_list_exempt', 'char', 'NULL', 1, '', '',
@@ -1653,6 +1706,7 @@ sub tables_hashref {
                           [ 'archived' ],
                           [ 'ship_locationnum' ],
                           [ 'bill_locationnum' ],
+                          [ 'is_tokenized' ],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'agentnum' ],
@@ -1692,7 +1746,7 @@ sub tables_hashref {
         'weight',          'int', 'NULL',        '', '', '', 
         'payby',          'char',     '',         4, '', '', 
         'payinfo',     'varchar', 'NULL',       512, '', '', 
-        'cardtype',    'varchar', 'NULL',   $char_d, '', '',
+        'paycardtype', 'varchar', 'NULL',   $char_d, '', '',
         'paycvv',      'varchar', 'NULL',       512, '', '', 
         'paymask',     'varchar', 'NULL',   $char_d, '', '', 
         #'paydate',   @date_type, '', '', 
@@ -1705,10 +1759,11 @@ sub tables_hashref {
         'paytype',     'varchar', 'NULL',   $char_d, '', '', 
         'payip',       'varchar', 'NULL',        15, '', '', 
         'locationnum',     'int', 'NULL',        '', '', '',
+        'is_tokenized',   'char', 'NULL',         1, '', '', 
       ],
       'primary_key'  => 'custpaybynum',
       'unique'       => [],
-      'index'        => [ [ 'custnum' ] ],
+      'index'        => [ [ 'custnum' ], [ 'is_tokenized' ] ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
@@ -1738,7 +1793,8 @@ sub tables_hashref {
         'classnum',              'int', 'NULL',  '', '', '',
         'comment',           'varchar', 'NULL', 255, '', '',
         'selfservice_access',   'char', 'NULL',   1, '', '',
-        'invoice_dest',         'char', 'NULL',       1, '', '',
+        'invoice_dest',         'char', 'NULL',   1, '', '', # Y or NULL
+        'message_dest',         'char', 'NULL',   1, '', '', # Y or NULL
       ],
       'primary_key'  => 'custcontactnum',
       'unique'       => [ [ 'custnum', 'contactnum' ], ],
@@ -1901,14 +1957,15 @@ sub tables_hashref {
     'quotation' => {
       'columns' => [
         #regular fields
-        'quotationnum',   'serial',     '', '', '', '', 
-        'prospectnum',       'int', 'NULL', '', '', '',
-        'custnum',           'int', 'NULL', '', '', '',
-        '_date',        @date_type,             '', '', 
-        'disabled',         'char', 'NULL',  1, '', '', 
-        'usernum',           'int', 'NULL', '', '', '',
-        'close_date',   @date_type,             '', '', 
-        'confidence',        'int', 'NULL', '', '', '',
+        'quotationnum',           'serial',     '', '',   '', '', 
+        'prospectnum',               'int', 'NULL', '',   '', '',
+        'custnum',                   'int', 'NULL', '',   '', '',
+        '_date',                @date_type,               '', '', 
+        'disabled',                 'char', 'NULL',  1,   '', '', 
+        'usernum',                   'int', 'NULL', '',   '', '',
+        'close_date',           @date_type,               '', '', 
+        'confidence',                'int', 'NULL', '',   '', '',
+        'quotation_description', 'varchar', 'NULL', '50', '', '',
         #'total',      @money_type,       '', '', 
         #'quotation_term', 'varchar', 'NULL', $char_d, '', '',
       ],
@@ -2038,9 +2095,12 @@ sub tables_hashref {
         'district',        'varchar', 'NULL',      20, '', '',
         'censustract',     'varchar', 'NULL',      20, '', '',
         'censusyear',         'char', 'NULL',       4, '', '',
+
+        #used only in... DSL qualification?  .CA DSL qualification?
         'location_type',   'varchar', 'NULL',      20, '', '',
         'location_number', 'varchar', 'NULL',      20, '', '',
         'location_kind',      'char', 'NULL',       1, '', '',
+
         'incorporated',       'char', 'NULL',       1, '', '',
         'disabled',           'char', 'NULL',       1, '', '', 
       ],
@@ -2314,6 +2374,7 @@ sub tables_hashref {
         'taxratelocationnum', 'serial',  '',     '', '', '', 
         'data_vendor',        'varchar', 'NULL', $char_d, '', '',
         'geocode',            'varchar', '',     20,      '', '', 
+        'district',           'varchar', 'NULL', $char_d, '', '',
         'city',               'varchar', 'NULL', $char_d, '', '',
         'county',             'varchar', 'NULL', $char_d, '', '',
         'state',              'char',    'NULL',       2, '', '', 
@@ -2375,7 +2436,7 @@ sub tables_hashref {
     'cust_pay_pending' => {
       'columns' => [
         'paypendingnum',      'serial',     '',      '', '', '',
-        'custnum',               'int',     '',      '', '', '', 
+        'custnum',               'int', 'NULL',      '', '', '', 
         'paid',            @money_type,                  '', '', 
         'currency',             'char', 'NULL',       3, '', '',
         '_date',            @date_type,                  '', '', 
@@ -2399,11 +2460,13 @@ sub tables_hashref {
         'manual',       'char',    'NULL',   1, '', '',
         'discount_term','int',     'NULL',  '', '', '',
         'failure_status','varchar','NULL',  16, '', '',
+        'is_tokenized',   'char', 'NULL',    1, '', '', 
       ],
       'primary_key'  => 'paypendingnum',
       'unique'       => [ [ 'payunique' ] ],
       'index'        => [ [ 'custnum' ], [ 'status' ],
                           ['paynum'], ['void_paynum'], ['jobnum'], ['invnum'],
+                          [ 'is_tokenized' ],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
@@ -2442,6 +2505,7 @@ sub tables_hashref {
         'usernum',         'int', 'NULL',      '', '', '',
         'payby',          'char',     '',       4, '', '',
         'payinfo',     'varchar', 'NULL',     512, '', '',
+        'paycardtype', 'varchar', 'NULL',   $char_d, '', '',
         'paymask',     'varchar', 'NULL', $char_d, '', '', 
         'paydate',     'varchar', 'NULL',      10, '', '', 
         'paybatch',    'varchar', 'NULL', $char_d, '', '',#for auditing purposes
@@ -2449,7 +2513,8 @@ sub tables_hashref {
         'closed',         'char', 'NULL',       1, '', '', 
         'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
         'no_auto_apply',  'char', 'NULL',       1, '', '', 
-
+        'is_tokenized',   'char', 'NULL',       1, '', '', 
+          
         # cash/check deposit info fields
         'bank',        'varchar', 'NULL', $char_d, '', '',
         'depositor',   'varchar', 'NULL', $char_d, '', '',
@@ -2462,12 +2527,12 @@ sub tables_hashref {
         'gatewaynum',      'int', 'NULL',      '', '', '', # payment_gateway FK
         'processor',   'varchar', 'NULL', $char_d, '', '', # module name
         'auth',        'varchar', 'NULL',      16, '', '', # CC auth number
-        'order_number','varchar', 'NULL', $char_d, '', '', # transaction number
+        'order_number','varchar', 'NULL', 256, '', '', # transaction number
       ],
       'primary_key'  => 'paynum',
       #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ],
       'index'        => [ ['custnum'], ['paybatch'], ['payby'], ['_date'],
-                          ['usernum'],
+                          ['usernum'], ['is_tokenized'], 
                         ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
@@ -2499,11 +2564,13 @@ sub tables_hashref {
         'usernum',         'int', 'NULL',      '', '', '',
         'payby',          'char',     '',       4, '', '',
         'payinfo',     'varchar', 'NULL',     512, '', '',
-       'paymask',     'varchar', 'NULL', $char_d, '', '', 
+        'paycardtype', 'varchar', 'NULL',   $char_d, '', '',
+        'paymask',     'varchar', 'NULL', $char_d, '', '', 
         #'paydate' ?
         'paybatch',    'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
         'closed',        'char',  'NULL',       1, '', '', 
         'pkgnum', 'int',   'NULL', '', '', '', #desired pkgnum for pkg-balances
+        'is_tokenized',   'char', 'NULL',       1, '', '', 
 
         # cash/check deposit info fields
         'bank',       'varchar', 'NULL', $char_d, '', '',
@@ -2516,7 +2583,7 @@ sub tables_hashref {
         'gatewaynum',      'int', 'NULL',      '', '', '', # payment_gateway FK
         'processor',   'varchar', 'NULL', $char_d, '', '', # module name
         'auth',        'varchar', 'NULL',      16, '', '', # CC auth number
-        'order_number','varchar', 'NULL', $char_d, '', '', # transaction number
+        'order_number','varchar', 'NULL', 256, '', '', # transaction number
 
         #void fields
         'void_date',  @date_type,                  '', '', 
@@ -2526,7 +2593,9 @@ sub tables_hashref {
       ],
       'primary_key'  => 'paynum',
       'unique'       => [],
-      'index'        => [ ['custnum'], ['usernum'], ['void_usernum'] ],
+      'index'        => [ ['custnum'], ['usernum'], ['void_usernum'],
+                          ['is_tokenized'],
+                        ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
@@ -2667,6 +2736,7 @@ sub tables_hashref {
         'country',          'char',     '',       2, '', '', 
         'payby',            'char',     '',       4, '', '',
         'payinfo',       'varchar', 'NULL',     512, '', '', 
+        #'paymask',       'varchar', 'NULL', $char_d, '', '',
         #'exp',          @date_type,                  '', '',
         'exp',           'varchar', 'NULL',      11, '', '', 
         'payname',       'varchar', 'NULL', $char_d, '', '', 
@@ -2676,10 +2746,11 @@ sub tables_hashref {
         'status',        'varchar', 'NULL', $char_d, '', '', 
         'failure_status','varchar', 'NULL',      16, '', '',
         'error_message', 'varchar', 'NULL', $char_d, '', '',
+        'paycode',       'varchar', 'NULL', $char_d, '', '',
       ],
       'primary_key'  => 'paybatchnum',
       'unique'       => [],
-      'index'        => [ ['batchnum'], ['invnum'], ['custnum'] ],
+      'index'        => [ ['batchnum'], ['invnum'], ['custnum'],['status'] ],
       'foreign_keys' => [
                           { columns    => [ 'batchnum' ],
                             table      => 'pay_batch',
@@ -3058,7 +3129,8 @@ sub tables_hashref {
                                                      # be index into payby
                                                      # table eventually
         'payinfo',      'varchar',   'NULL', 512, '', '', #see cust_main above
-       'paymask', 'varchar', 'NULL', $char_d, '', '', 
+        'paycardtype',  'varchar', 'NULL',   $char_d, '', '',
+        'paymask', 'varchar', 'NULL', $char_d, '', '', 
         'paybatch',     'varchar',   'NULL', $char_d, '', '', 
         'closed',    'char', 'NULL', 1, '', '', 
         'source_paynum', 'int', 'NULL', '', '', '', # link to cust_payby, to prevent unapply of gateway-generated refunds
@@ -3067,10 +3139,11 @@ sub tables_hashref {
         'processor',  'varchar', 'NULL', $char_d, '', '', # module name
         'auth',       'varchar','NULL',16, '', '', # CC auth number
         'order_number', 'varchar','NULL',$char_d, '', '', # transaction number
+        'is_tokenized',   'char', 'NULL',    1, '', '', 
       ],
       'primary_key'  => 'refundnum',
       'unique'       => [],
-      'index'        => [ ['custnum'], ['_date'], [ 'usernum' ], ],
+      'index'        => [ ['custnum'], ['_date'], [ 'usernum' ], ['is_tokenized'] ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
@@ -3197,7 +3270,7 @@ sub tables_hashref {
       'columns' => [
         'pkgpart',       'serial',    '',   '', '', '', 
         'pkgpartbatch',  'varchar', 'NULL', $char_d, '', '',
-        'pkg',           'varchar',   '',   $char_d, '', '', 
+        'pkg',           'varchar',   '',   104, '', '', 
         'comment',       'varchar', 'NULL', 2*$char_d, '', '', 
         'promo_code',    'varchar', 'NULL', $char_d, '', '', 
         'freq',          'varchar',   '',   $char_d, '', '', #billing frequency
@@ -3229,6 +3302,7 @@ sub tables_hashref {
         'adjourn_months', 'int',    'NULL', '', '', '',
         'contract_end_months','int','NULL', '', '', '',
         'change_to_pkgpart', 'int', 'NULL', '', '', '',
+        'units_taxproductnum','int','NULL', '', '', '',
       ],
       'primary_key'  => 'pkgpart',
       'unique'       => [],
@@ -3246,6 +3320,10 @@ sub tables_hashref {
                           { columns    => [ 'taxproductnum' ],
                             table      => 'part_pkg_taxproduct',
                           },
+                          { columns    => [ 'units_taxproductnum' ],
+                            table      => 'part_pkg_taxproduct',
+                            references => [ 'taxproductnum' ],
+                          },
                           { columns    => [ 'agentnum' ],
                             table      => 'agent',
                           },
@@ -3590,10 +3668,11 @@ sub tables_hashref {
         'refnum',   'serial',     '',        '', '', '', 
         'referral', 'varchar',    '',   $char_d, '', '', 
         'disabled', 'char',   'NULL',         1, '', '', 
-        'agentnum', 'int',    'NULL',        '', '', '', 
+        'agentnum', 'int',    'NULL',        '', '', '',
+        'title',   'varchar', 'NULL',   $char_d, '', '', 
       ],
       'primary_key'  => 'refnum',
-      'unique'       => [],
+      'unique'       => [ ['agentnum', 'title'] ],
       'index'        => [ ['disabled'], ['agentnum'], ],
       'foreign_keys' => [
                           { columns    => [ 'agentnum' ],
@@ -3680,6 +3759,24 @@ sub tables_hashref {
                         ],
     },
 
+    'part_svc_msgcat' => {
+      'columns' => [
+        'svcpartmsgnum',  'serial',     '',        '', '', '',
+        'svcpart',           'int',     '',        '', '', '',
+        'locale',        'varchar',     '',        16, '', '',
+        'svc',           'varchar',     '',   $char_d, '', '',
+      ],
+      'primary_key'  => 'svcpartmsgnum',
+      'unique'       => [ [ 'svcpart', 'locale' ] ],
+      'index'        => [],
+      'foreign_keys' => [
+                          { columns    => [ 'svcpart' ],
+                            table      => 'part_svc',
+                          },
+                        ],
+    },
+
+
     #(this should be renamed to part_pop)
     'svc_acct_pop' => {
       'columns' => [
@@ -3868,9 +3965,12 @@ sub tables_hashref {
       'unique'       => [],
       'index'        => [ ['svcnum', 'transaction_id'] ],
       'foreign_keys' => [
-                          { columns    => [ 'svcnum' ],
-                            table      => 'svc_acct', #'cust_svc',
-                          },
+                          # problems w/deleted services, and as per below, this
+                          # is our internal hack, not a customer-facing feature
+                          #{ columns    => [ 'svcnum' ],
+                          #  table      => 'svc_acct', #'cust_svc',
+                          #},
+
                           # 1. RT tables aren't part of our data structure, so
                           #     we can't make sure Queue is created already
                           # 2. This is our internal hack for time tracking, not
@@ -4068,7 +4168,7 @@ sub tables_hashref {
         'note',     'text',    'NULL',      '', '', '',
       ],
       'primary_key'  => 'svcnum',
-      'unique'       => [],
+      'unique'       => [ ['typenum', 'serial'], ['ip_addr'], ['hw_addr'] ],
       'index'        => [],
       'foreign_keys' => [
                           { columns    => [ 'svcnum' ],
@@ -4099,6 +4199,7 @@ sub tables_hashref {
         'classnum',    'int',     '',      '', '', '',
         'model',   'varchar',     '', $char_d, '', '',
         'revision','varchar', 'NULL', $char_d, '', '',
+        'title',   'varchar', 'NULL', $char_d, '', '', # external id
       ],
       'primary_key'  => 'typenum',
       'unique'       => [ [ 'classnum', 'model', 'revision' ] ],
@@ -4790,6 +4891,9 @@ sub tables_hashref {
         'suid',                    'int', 'NULL',        '', '', '',
         'shared_svcnum',           'int', 'NULL',        '', '', '',
         'serviceid',           'varchar', 'NULL',        64, '', '',#srvexport/reportfields
+        'speed_test_up',           'int', 'NULL',        '', '', '',
+        'speed_test_down',         'int', 'NULL',        '', '', '',
+        'speed_test_latency',      'int', 'NULL',        '', '', '',
       ],
       'primary_key'  => 'svcnum',
       'unique'       => [ [ 'ip_addr' ], [ 'mac_addr' ] ],
@@ -4827,6 +4931,8 @@ sub tables_hashref {
         'height',     'decimal', 'NULL',      '', '', '', 
         'veg_height', 'decimal', 'NULL',      '', '', '', 
         'color',      'varchar', 'NULL',       6, '', '',
+        'up_rate_limit',        'int', 'NULL',      '', '', '',
+        'down_rate_limit',      'int', 'NULL',      '', '', '',
       ],
       'primary_key' => 'towernum',
       'unique'      => [ [ 'towername' ] ], # , 'agentnum' ] ],
@@ -4843,9 +4949,24 @@ sub tables_hashref {
         'freq_mhz',         'int', 'NULL',      '', '', '',
         'direction',        'int', 'NULL',      '', '', '',
         'width',            'int', 'NULL',      '', '', '',
-        #downtilt etc? rfpath has profile files for devices/antennas you upload?
         'sector_range', 'decimal', 'NULL',      '', '', '',  #?
-      ],
+        'downtilt',     'decimal', 'NULL',      '', '', '',
+        'v_width',          'int', 'NULL',      '', '', '',
+        'power',        'decimal', 'NULL',      '', '', '',
+        'line_loss',    'decimal', 'NULL',      '', '', '',
+        'antenna_gain', 'decimal', 'NULL',     '', '', '',
+        'hardware_typenum', 'int', 'NULL',     '', '', '',
+        'db_high',          'int', 'NULL',     '', '', '',
+        'db_low',           'int', 'NULL',     '', '', '',
+        'image',           'blob', 'NULL',     '', '', '',
+        'west',         'decimal', 'NULL', '10,7', '', '',
+        'east',         'decimal', 'NULL', '10,7', '', '',
+        'south',        'decimal', 'NULL', '10,7', '', '',
+        'north',        'decimal', 'NULL', '10,7', '', '',
+        'title',        'varchar', 'NULL', $char_d,'', '',
+        'up_rate_limit',          'int', 'NULL',      '', '', '',
+        'down_rate_limit',        'int', 'NULL',      '', '', '',
+     ],
       'primary_key'  => 'sectornum',
       'unique'       => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
       'index'        => [ [ 'towernum' ] ],
@@ -4853,6 +4974,27 @@ sub tables_hashref {
                           { columns    => [ 'towernum' ],
                             table      => 'tower',
                           },
+                          { columns    => [ 'hardware_typenum' ],
+                            table      => 'hardware_type',
+                            references => [ 'typenum' ],
+                          },
+                        ],
+    },
+
+    'sector_coverage' => {
+      'columns' => [
+        'coveragenum', 'serial', '', '', '', '',
+        'sectornum',     'int', '', '', '', '',
+        'db_loss',       'int', '', '', '', '',
+        'geometry',     'text', 'NULL', '', '', '',
+      ],
+      'primary_key' => 'coveragenum',
+      'unique' => [],
+      'index'  => [],
+      'foreign_keys' => [
+                          { columns => [ 'sectornum' ],
+                            table   => 'tower_sector'
+                          },
                         ],
     },
 
@@ -5136,7 +5278,7 @@ sub tables_hashref {
         'ocn',         'char',    'NULL',       4, '', '', 
       ],
       'primary_key'  => 'prefixnum',
-      'unique'       => [],
+      'unique'       => [ [ 'countrycode', 'npa', 'nxx' ] ],
       'index'        => [ [ 'countrycode' ], [ 'npa' ], [ 'regionnum' ] ],
       'foreign_keys' => [
                           { columns    => [ 'regionnum' ],
@@ -5504,6 +5646,10 @@ sub tables_hashref {
         'rated_ratename',         'varchar', 'NULL', $char_d, '', '', 
         'rated_cost',            'decimal', 'NULL',  '10,4', '', '',
 
+        # real endpoints of the call
+        'src_lrn',             'varchar', 'NULL',     '15', '', '',
+        'dst_lrn',             'varchar', 'NULL',     '15', '', '',
+
         'carrierid',               'bigint', 'NULL',      '', '', '',
 
         # service it was matched to
@@ -5522,9 +5668,6 @@ sub tables_hashref {
         'sessionnum',       'int',    'NULL',      '', '', '',
         'subscriber',   'varchar',    'NULL', $char_d, '', '',
 
-        #old
-        'cdrbatch',     'varchar',    'NULL',     255, '', '',
-        #new
         'cdrbatchnum',      'int',    'NULL',      '', '', '',
 
         # FK to cust_bill_pkg_detail; having a value here absolutely means
@@ -5535,11 +5678,13 @@ sub tables_hashref {
       'unique' => [],
       'index' => [ [ 'calldate' ],
                    [ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ],
+                   [ 'startdate' ], [ 'duration' ],
+                   [ 'cdrtypenum' ], [ 'calltypenum' ],
                    [ 'lastapp' ],
                    ['accountcode'], ['uniqueid'], ['carrierid'], ['cdrid'],
                    [ 'sessionnum' ], [ 'subscriber' ],
                    [ 'freesidestatus' ], [ 'freesiderewritestatus' ],
-                   [ 'cdrbatch' ], [ 'cdrbatchnum' ],
+                   [ 'cdrbatchnum' ],
                    [ 'src_ip_addr' ], [ 'dst_ip_addr' ], [ 'dst_term' ],
                    [ 'detailnum' ],
                  ],
@@ -5566,6 +5711,7 @@ sub tables_hashref {
         'rated_price',  'decimal', 'NULL',  '10,4', '', '',
         'rated_seconds',    'int', 'NULL',      '', '', '',
         'rated_minutes', 'double precision', 'NULL',   '', '', '',
+        'rated_granularity','int', 'NULL',      '', '', '',
         'status',       'varchar', 'NULL',      32, '', '',
         'svcnum',           'int', 'NULL',      '', '', '',
       ],
@@ -5694,6 +5840,25 @@ sub tables_hashref {
                         ],
     },
 
+    'access_user_session_log' => {
+      'columns' => [
+        'sessionlognum', 'serial', '',      '', '', '',
+        'usernum',          'int', '',      '', '', '',
+        'start_date',  @date_type,              '', '',
+        'last_date',   @date_type,              '', '',
+        'logout_date', @date_type,              '', '',
+        'logout_type',  'varchar', '', $char_d, '', '',
+      ],
+      'primary_key' => 'sessionlognum',
+      'unique'       => [],
+      'index'        => [],
+      'foreign_keys' => [
+                          { columns    => [ 'usernum' ],
+                            table      => 'access_user',
+                          },
+                        ],
+    },
+
     'access_user' => {
       'columns' => [
         'usernum',             'serial',     '',      '', '', '',
@@ -5741,8 +5906,9 @@ sub tables_hashref {
 
     'access_group' => {
       'columns' => [
-        'groupnum',   'serial', '',      '', '', '',
-        'groupname', 'varchar', '', $char_d, '', '',
+        'groupnum',        'serial',     '',      '', '', '',
+        'groupname',      'varchar',     '', $char_d, '', '',
+        'session_timeout',    'int', 'NULL',      '', '', '',
       ],
       'primary_key' => 'groupnum',
       'unique' => [ [ 'groupname' ] ],
@@ -5806,12 +5972,33 @@ sub tables_hashref {
         'path',           'varchar',     '', 2*$char_d, '', '',
         '_date',                   @date_type,          '', '',
         'render_seconds',     'int', 'NULL',        '', '', '',
+        'pid',                'int', 'NULL',        '', '', '',
       ],
       'primary_key'  => 'lognum',
       'unique'       => [],
       'index'        => [ ['usernum'], ['path'], ['_date'] ],
     },
 
+    'access_user_page_pref' => {
+      'columns'     => [
+        'prefnum'     =>  'serial',     '',      '', '', '',
+        'usernum'     =>     'int',     '',      '', '', '',
+        'path'        =>    'text',     '',      '', '', '',
+        'tablenum'    =>     'int', 'NULL',      '', '', '',
+        '_date'       =>    @date_type,              '', '',
+        'prefname'    =>    'varchar',  '', $char_d, '', '',
+        'prefvalue'   =>    'text',     '',      '', '', '',
+      ],
+      'primary_key' => 'prefnum',
+      'unique'      => [ [ 'usernum', 'path', 'tablenum', 'prefname' ] ],
+      'index'       => [],
+      'foreign_keys' => [
+                          { columns   => [ 'usernum' ],
+                            table     => 'access_user'
+                          },
+                        ],
+    },
+
     'sched_item' => {
       'columns' => [
         'itemnum',   'serial',      '', '', '', '', 
@@ -5873,6 +6060,9 @@ sub tables_hashref {
         'lnp_other_provider',         'varchar', 'NULL', $char_d, '', '',
         'lnp_other_provider_account', 'varchar', 'NULL', $char_d, '', '',
         'lnp_reject_reason',          'varchar', 'NULL', $char_d, '', '',
+        'lnp_portid',                 'varchar', 'NULL', $char_d, '', '',
+        'lnp_signature',                 'char', 'NULL',       1, '', '',
+        'lnp_bill',                      'char', 'NULL',       1, '', '',
         'sms_carrierid',                  'int', 'NULL',      '', '', '',
         'sms_account',                'varchar', 'NULL', $char_d, '', '',
         'max_simultaneous',               'int', 'NULL',      '', '', '',
@@ -6603,6 +6793,7 @@ sub tables_hashref {
         'min_level', 'int',  'NULL', '', '', '',
         'msgnum', 'int', '',  '', '', '',
         'to_addr', 'varchar', 'NULL',     255, '', '',
+        'context_height',  'int', 'NULL', '', '', '', 
       ],
       'primary_key'  => 'logemailnum',
       'unique'       => [],
@@ -6711,7 +6902,7 @@ sub tables_hashref {
         'mac_addr',  'varchar', 'NULL',      12, '', '', 
       ],
       'primary_key'  => 'svcnum',
-      'unique'       => [ ['serialnum'] , ['mac_addr'] ],
+      'unique'       => [ ['modelnum', 'serialnum'] , ['mac_addr'] ],
       'index'        => [],
       'foreign_keys' => [
                           { columns    => [ 'svcnum' ],
@@ -6869,6 +7060,7 @@ sub tables_hashref {
         'vendor_order_status',  'varchar', 'NULL', $char_d,  '', '',
         'endpoint_ip_addr',     'varchar', 'NULL', 40, '', '',
         'endpoint_mac_addr',    'varchar', 'NULL', 12, '', '',
+        'internal_circuit_id',  'varchar', 'NULL', 64, '', '',
       ],
       'primary_key' => 'svcnum',
       'unique'      => [],
@@ -7248,6 +7440,7 @@ sub tables_hashref {
         'graphnum',       'int',      'NULL', '', '', '', 
         'imported',       @date_type,             '', '',
         'content',        'text',     'NULL', '', '', '',
+        'thumbnail',      'text',     'NULL', '', '', '',
       ],
       'primary_key' => 'cacti_pagenum',
       'unique'  => [ ],
@@ -7364,6 +7557,143 @@ sub tables_hashref {
                         ],
     },
 
+    'rt_field_charge' => {
+      'columns' => [
+        'rtfieldchargenum',    'serial',      '',      '', '', '',
+        'pkgnum',                 'int',      '',      '', '', '', 
+        'ticketid',               'int',      '',      '', '', '', 
+        'rate',             @money_type,                   '', '', 
+        'units',              'decimal',      '',  '10,4', '', '',
+        'charge',           @money_type,                   '', '', 
+        '_date',             @date_type,                   '', '',
+      ],
+      'primary_key'  => 'rtfieldchargenum',
+      'unique'       => [],
+      'index'        => [ ['pkgnum', 'ticketid'] ],
+      'foreign_keys' => [
+                          { columns    => [ 'pkgnum' ],
+                            table      => 'cust_pkg',
+                          },
+                        ],
+    },
+
+    'commission_schedule' => {
+      'columns' => [
+        'schedulenum',    'serial',     '',      '', '', '',
+        'schedulename',  'varchar',     '', $char_d, '', '',
+        'reasonnum',         'int', 'NULL',      '', '', '',
+        'basis',         'varchar', 'NULL',      32, '', '',
+      ],
+      'primary_key'  => 'schedulenum',
+      'unique'       => [],
+      'index'        => [],
+    },
+
+    'commission_rate' => {
+      'columns' => [
+        'commissionratenum', 'serial',     '',      '', '', '',
+        'schedulenum',       'int',     '',      '', '', '',
+        'cycle',             'int',     '',      '', '', '',
+        'amount',            @money_type,          '', '', 
+        'percent',           'decimal','',   '7,4', '', '',
+      ],
+      'primary_key'  => 'commissionratenum',
+      'unique'       => [ [ 'schedulenum', 'cycle', ] ],
+      'index'        => [],
+      'foreign_keys' => [
+                          { columns => [ 'schedulenum' ],
+                            table   => 'commission_schedule',
+                          },
+                        ],
+    },
+
+    'saved_search' => {
+      'columns' => [
+        'searchnum',    'serial',  '',          '', '', '',
+        'usernum',      'int',     'NULL',      '', '', '',
+        'searchname',   'varchar', '',     $char_d, '', '',
+        'path',         'varchar', '',     $char_d, '', '',
+        'params',       'text',    'NULL',      '', '', '',
+        'disabled',     'char',    'NULL',       1, '', '',
+        'freq',         'varchar', 'NULL',      16, '', '',
+        'last_sent',    'int',     'NULL',      '', '', '',
+        'format',       'varchar', 'NULL',      32, '', '',
+      ],
+      'primary_key'   => 'searchnum',
+      'unique'        => [],
+      'index'         => [],
+      'foreign_keys'  => [
+                           { columns => [ 'usernum' ],
+                             table   => 'access_user',
+                           },
+                         ],
+    },
+
+    'addr_status' => {
+      'columns' => [
+        'addrnum',  'serial',      '', '', '', '',
+        'ip_addr',  'varchar', 'NULL', 40, '', '',
+        '_date',    @date_type,            '', '',
+        'up',       'char',    'NULL',  1, '', '',
+        'delay',    'int',     'NULL', '', '', '',
+      ],
+      'primary_key'   => 'addrnum',
+      'unique'        => [ [ 'ip_addr' ] ],
+      'index'         => [ [ '_date' ] ],
+      'foreign_keys'  => [],
+    },
+
+    'realestate_unit' => {
+      'columns' => [
+        'realestatenum',    'serial',  '',     '',      '',  '',
+        'realestatelocnum', 'int',     '',     '',      '',  '',
+        'agentnum',         'int',     'NULL', '',      '',  '',
+        'unit_title',       'varchar', '',     $char_d, '',  '',
+        'disabled',         'char',    'NULL', 1,       '',  '',
+      ],
+      'primary_key'  => 'realestatenum',
+      'unique'       => [ ['unit_title'] ],
+      'index'        => [
+        ['agentnum'],
+        ['realestatelocnum'],
+        ['disabled'],
+        ['unit_title'],
+      ],
+      'foreign_keys' => [
+        {columns => ['agentnum'], table => 'agent'},
+        {columns => ['realestatelocnum'] => table => 'realestate_location'},
+      ],
+    },
+
+    realestate_location => {
+      'columns' => [
+        'realestatelocnum', 'serial',  '',     '',      '', '',
+        'agentnum',         'int',     'NULL', '',      '', '',
+       'location_title',   'varchar', '',     $char_d, '', '',
+        'address1',         'varchar', 'NULL', $char_d, '',  '',
+        'address2',         'varchar', 'NULL', $char_d, '',  '',
+        'city',             'varchar', 'NULL', $char_d, '',  '',
+        'state',            'varchar', 'NULL', $char_d, '',  '',
+        'zip',              'char',    'NULL', 5,       '',  '',
+        'disabled',         'char',    'NULL', 1,       '',  '',
+      ],
+      primary_key  => 'realestatelocnum',
+      'unique'     => [ ['location_title'] ],
+      'index'      => [ ['agentnum'], ['disabled'] ],
+      'foreign_keys' => [
+        {columns => ['agentnum'], table => 'agent'},
+      ],
+    },
+
+    svc_realestate => {
+      columns => [
+        'svcnum',        'serial',  '',     '',      '', '',
+        'realestatenum', 'int',     'NULL', '',      '', '',
+      ],
+      primary_key => 'svcnum',
+      index => [],
+    },
+
     # name type nullability length default local
 
     #'new_table' => {
@@ -7390,4 +7720,3 @@ L<DBIx::DBSchema>
 =cut
 
 1;
-