per-agent invoice PDF batches, RT#13727
[freeside.git] / FS / FS / Schema.pm
index 9d03ce3..6fde8b1 100644 (file)
@@ -117,6 +117,7 @@ sub dbdef_dist {
     #false laziness w/sub indices in DBIx::DBSchema::DBD (well, sorta)
     #and sub sql_create_table in DBIx::DBSchema::Table (slighty more?)
     my $unique = $tables_hashref->{$tablename}{'unique'};
+    warn "missing index for $tablename\n" unless defined $tables_hashref->{$tablename}{'index'};
     my @index  = @{ $tables_hashref->{$tablename}{'index'} };
 
     # kludge to avoid avoid "BLOB/TEXT column 'statustext' used in key
@@ -197,34 +198,42 @@ sub dbdef_dist {
     my $tableobj = $dbdef->table($table)
       or die "unknown table $table";
 
-    my %indices = $tableobj->indices;
+    my %h_indices = ();
+
+    unless ( $table eq 'cust_event' ) { #others?
+
+      my %indices = $tableobj->indices;
     
-    my %h_indices = map { 
-                          ( "h_$_" =>
-                              DBIx::DBSchema::Index->new({
-                                'name'    => 'h_'. $indices{$_}->name,
-                                'unique'  => 0,
-                                'columns' => [ @{$indices{$_}->columns} ],
-                              })
-                          );
-                        }
-                        keys %indices;
-
-    $h_indices{"h_${table}_srckey"} = DBIx::DBSchema::Index->new({
-                                        'name'    => "h_${table}_srckey",
-                                        'unique'  => 0,
-                                        'columns' => [ 'history_action', #right?
-                                                       $tableobj->primary_key,
-                                                     ],
-                                      });
-
-    $h_indices{"h_${table}_srckey2"} = DBIx::DBSchema::Index->new({
-                                         'name'    => "h_${table}_srckey2",
-                                         'unique'  => 0,
-                                         'columns' => [ 'history_date',
-                                                        $tableobj->primary_key,
-                                                      ],
-                                       });
+      %h_indices = map { 
+                         ( "h_$_" =>
+                             DBIx::DBSchema::Index->new({
+                               'name'    => 'h_'. $indices{$_}->name,
+                               'unique'  => 0,
+                               'columns' => [ @{$indices{$_}->columns} ],
+                             })
+                         );
+                       }
+                       keys %indices;
+
+      $h_indices{"h_${table}_srckey"} =
+        DBIx::DBSchema::Index->new({
+          'name'    => "h_${table}_srckey",
+          'unique'  => 0,
+          'columns' => [ 'history_action', #right?
+                         $tableobj->primary_key,
+                       ],
+        });
+
+      $h_indices{"h_${table}_srckey2"} =
+         DBIx::DBSchema::Index->new({
+           'name'    => "h_${table}_srckey2",
+           'unique'  => 0,
+           'columns' => [ 'history_date',
+                          $tableobj->primary_key,
+                        ],
+         });
+
+    }
 
     my $h_tableobj = DBIx::DBSchema::Table->new( {
       'name'          => "h_$table",
@@ -873,6 +882,7 @@ sub tables_hashref {
         'email_csv_cdr', 'char', 'NULL', 1, '', '',
         'accountcode_cdr', 'char', 'NULL', 1, '', '',
         'billday',   'int', 'NULL', '', '', '',
+        'edit_subject', 'char', 'NULL', 1, '', '',
       ],
       'primary_key' => 'custnum',
       'unique' => [ [ 'agentnum', 'agent_custid' ] ],
@@ -1436,6 +1446,7 @@ sub tables_hashref {
         'cancel',         @date_type,             '', '', 
         'expire',         @date_type,             '', '', 
         'contract_end',   @date_type,             '', '',
+        'dundate',        @date_type,             '', '',
         'change_date',    @date_type,             '', '',
         'change_pkgnum',       'int', 'NULL', '', '', '',
         'change_pkgpart',      'int', 'NULL', '', '', '',
@@ -1445,6 +1456,8 @@ sub tables_hashref {
         'quantity',            'int', 'NULL', '', '', '',
         'agent_pkgid',         'int', 'NULL', '', '', '',
         'waive_setup',        'char', 'NULL',  1, '', '', 
+        'recur_show_zero',    'char', 'NULL',  1, '', '',
+        'setup_show_zero',    'char', 'NULL',  1, '', '',
       ],
       'primary_key' => 'pkgnum',
       'unique' => [],
@@ -1626,7 +1639,9 @@ sub tables_hashref {
         'credit_weight', 'real',    'NULL', '', '', '',
         'agentnum',      'int',     'NULL', '', '', '', 
         'fcc_ds0s',      'int',     'NULL', '', '', '', 
-        'no_auto',      'char',     'NULL',  1, '', '', 
+        'no_auto',          'char', 'NULL',  1, '', '', 
+        'recur_show_zero',  'char', 'NULL',  1, '', '',
+        'setup_show_zero',  'char', 'NULL',  1, '', '',
       ],
       'primary_key' => 'pkgpart',
       'unique' => [],
@@ -2327,12 +2342,24 @@ sub tables_hashref {
       'columns' => [
         'usergroupnum', 'serial', '', '', '', '', 
         'svcnum',       'int', '', '', '', '', 
-        'groupname',    'varchar', '', $char_d, '', '', 
+        'groupname',    'varchar', 'NULL', $char_d, '', '', 
+        'groupnum',     'int', 'NULL', '', '', '', 
       ],
       'primary_key' => 'usergroupnum',
       'unique'      => [],
       'index'       => [ [ 'svcnum' ], [ 'groupname' ] ],
     },
+    
+    'radius_group' => {
+      'columns' => [
+        'groupnum', 'serial', '', '', '', '', 
+        'groupname',    'varchar', '', $char_d, '', '', 
+        'description',  'varchar', 'NULL', $char_d, '', '', 
+      ],
+      'primary_key' => 'groupnum',
+      'unique'      => [ ['groupname'] ],
+      'index'       => [],
+    },
 
     'msgcat' => {
       'columns' => [
@@ -2444,9 +2471,7 @@ sub tables_hashref {
         'vfieldpart', 'serial', '', '', '', '', 
         'dbtable', 'varchar', '', 32, '', '', 
         'name', 'varchar', '', 32, '', '', 
-        'check_block', 'text', 'NULL', '', '', '', 
         'length', 'int', 'NULL', '', '', '', 
-        'list_source', 'text', 'NULL', '', '', '', 
         'label', 'varchar', 'NULL', 80, '', '', 
       ],
       'primary_key' => 'vfieldpart',
@@ -2593,6 +2618,9 @@ sub tables_hashref {
         'countrycode', 'varchar',     '',  3, '', '', 
         'npa',         'varchar', 'NULL', 10, '', '', #actually the whole prefix
         'nxx',         'varchar', 'NULL',  3, '', '', #actually not used
+        'latanum',     'int',     'NULL',      '', '', '',
+        'state',       'char',    'NULL',       2, '', '', 
+        'ocn',         'char',    'NULL',       4, '', '', 
       ],
       'primary_key' => 'prefixnum',
       'unique'      => [],
@@ -2726,14 +2754,16 @@ sub tables_hashref {
         'payby',   'char',     '',       4, '', '', 
         'payinfo', 'varchar',  '',     128, '', '', #say, a 512-big digest _hex encoded
        #'paymask', 'varchar',  'NULL', $char_d, '', ''
-        '_date',   @date_type, '', '', 
-        'otaker',  'varchar',  'NULL',     32, '', '', 
-        'usernum',   'int', 'NULL', '', '', '',
+        '_date',            @date_type,         '', '', 
+        'end_date',         @date_type,         '', '', 
+        'otaker',  'varchar',  'NULL',      32, '', '', 
+        'usernum',     'int',  'NULL',      '', '', '',
+        'bantype', 'varchar',  'NULL', $char_d, '', '',
         'reason',  'varchar',  'NULL', $char_d, '', '', 
       ],
       'primary_key' => 'bannum',
-      'unique'      => [ [ 'payby', 'payinfo' ] ],
-      'index'       => [ [ 'usernum' ] ],
+      'unique'      => [],
+      'index'       => [ [ 'payby', 'payinfo' ], [ 'usernum' ], ],
     },
 
     'pkg_category' => {
@@ -2755,6 +2785,7 @@ sub tables_hashref {
         'classname',   'varchar',  '', $char_d, '', '', 
         'categorynum', 'int',  'NULL',      '', '', '', 
         'disabled',    'char', 'NULL',       1, '', '', 
+        'fcc_ds0s',      'int',     'NULL', '', '', '', 
       ],
       'primary_key' => 'classnum',
       'unique' => [],
@@ -3131,6 +3162,7 @@ sub tables_hashref {
                     [ 'exportnum', 'countrycode', 'npa', 'nxx', 'station' ], # #
                     [ 'svcnum' ],
                     [ 'availbatch' ],
+                    [ 'latanum' ],
                   ],
     },
     
@@ -3138,6 +3170,7 @@ sub tables_hashref {
       'columns' => [
         'latanum',    'int',      '',      '', '', '', 
         'description',   'varchar',    '',      $char_d, '', '', 
+        'have_usage',   'int',    'NULL',      '', '', '', 
       ],
       'primary_key' => 'latanum',
       'unique' => [],
@@ -3184,6 +3217,7 @@ sub tables_hashref {
         'ratecenternum',      'int',     'NULL',      '', '', '',
         'state',       'char',    'NULL',       2, '', '', 
         'quantity',      'int',     '',      '', '', '',
+        'custnum',   'int', 'NULL', '', '', '',
       ],
       'primary_key' => 'orderitemnum',
       'unique' => [],
@@ -3305,13 +3339,14 @@ sub tables_hashref {
 
     'bill_batch' => {
       'columns' => [
-        'batchnum',         'serial',     '', '', '', '',
-        'status',             'char', 'NULL','1', '', '',
-        'pdf',                'blob', 'NULL', '', '', '',
+        'batchnum',         'serial',     '',  '', '', '',
+        'agentnum',            'int', 'NULL',  '', '', '',
+        'status',             'char', 'NULL', '1', '', '',
+        'pdf',                'blob', 'NULL',  '', '', '',
       ],
       'primary_key' => 'batchnum',
       'unique'      => [],
-      'index'       => [],
+      'index'       => [ ['agentnum'] ],
     },
 
     'cust_bill_batch' => {